diff --git a/vcarded.scm b/vcarded.scm index cd0dc8d..03a862b 100644 --- a/vcarded.scm +++ b/vcarded.scm @@ -50,8 +50,21 @@ ;; Splits a key or value-element into its (potentially multiple) parameters. +;; … basically just splits along non-escaped semi-colons. +;; "Bird;dad;apple\;mom" → ("Bird" "dad" "apple\;mom") (define (split-vcard-element key-or-value) - (irregex-extract "(\\\\;|[^;])*" key-or-value)) + (let [(appendee "")] + (remove + not + (map (lambda (str) + (let [(str (string-concatenate `(,appendee ,str)))] + (if (and (not (string-null? str)) + (eq? (last (string->list str)) + #\\)) + (and (set! appendee (string-concatenate `(,str ";"))) + #f) + (and (set! appendee "") str)))) + (string-split key-or-value ";"))))) ;; Parse a line of a vcard file into an alist-friendly format: