aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-06-05 21:48:11 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-06-05 21:48:11 +0200
commitb62ae7068837b18e83948abd1685f5b1b2da52d7 (patch)
treec8685c1b42dc089e41b8c93dadb15828092427a1
parentRemove incorrect output of DURATION. (diff)
downloadcalp-b62ae7068837b18e83948abd1685f5b1b2da52d7.tar.gz
calp-b62ae7068837b18e83948abd1685f5b1b2da52d7.tar.xz
Filter out ALL X-HNH- fields from ics output.
-rw-r--r--module/output/ical.scm10
-rw-r--r--module/util.scm4
-rw-r--r--module/vcomponent/parse/component.scm2
3 files changed, 11 insertions, 5 deletions
diff --git a/module/output/ical.scm b/module/output/ical.scm
index 02dd5d64..fd4091ed 100644
--- a/module/output/ical.scm
+++ b/module/output/ical.scm
@@ -97,6 +97,11 @@
(ical-line-fold (string-drop string wrap-len)))]
[else string]))
+(define* (internal-field? symbol optional: (prefix "X-HNH-"))
+ (string=? prefix
+ (string-take-to (symbol->string symbol)
+ (string-length prefix))))
+
(define-public (component->ical-string component)
(format #t "BEGIN:~a\r\n" (type component))
;; TODO this leaks internal information,
@@ -105,11 +110,8 @@
;; Special cases depending on key.
;; Value formatting is handled in @code{value-format}.
(match-lambda*
- ;; Handled below
- [('X-HNH-ALTERNATIVES _) 'noop]
- ;; Remove from output
- [('X-HNH-FILENAME _) 'noop]
+ [(? (compose internal-field? car)) 'noop]
[(key (vlines ...))
(for vline in vlines
diff --git a/module/util.scm b/module/util.scm
index b168ffc4..f41877b5 100644
--- a/module/util.scm
+++ b/module/util.scm
@@ -316,6 +316,10 @@
(if (> i (length lst))
lst (take lst i)))
+(define-public (string-take-to str i)
+ (if (> i (string-length str))
+ str (string-take str i)))
+
(define-public (as-string s)
(if (symbol? s) (symbol->string s) s))
diff --git a/module/vcomponent/parse/component.scm b/module/vcomponent/parse/component.scm
index 8526944a..d54f977a 100644
--- a/module/vcomponent/parse/component.scm
+++ b/module/vcomponent/parse/component.scm
@@ -62,7 +62,7 @@
(let ((datetime (parse-ics-datetime value tz)))
(hashq-set! params 'VALUE 'DATE-TIME)
(values (make-vline key (get-datetime datetime) params)
- (make-vline (symbol-append 'X-ORIGINAL- key) datetime params)))
+ (make-vline (symbol-append 'X-HNH-ORIGINAL- key) datetime params)))
(begin (hashq-set! params 'VALUE 'DATE)
(make-vline key (parse-ics-date value) params)))))]