From 8e73f121becaeece8eec7d19187e835124a6041b Mon Sep 17 00:00:00 2001 From: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com> Date: Tue, 6 Feb 2024 12:11:26 -0600 Subject: [PATCH] Fix broken property-splitting Also, now we avoid using regex, which is apparently more efficient, According to TIME. --- vcarded.scm | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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: