From 23789db7ed409ccafc079d5fe9e9d0c32b66abe5 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sun, 7 Mar 2021 03:36:52 +0530 Subject: Escape YAML strings that contain the hyphen character. * ccwl/yaml.scm (display-atom): Escape string if it contains the hyphen character. --- ccwl/yaml.scm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ccwl/yaml.scm b/ccwl/yaml.scm index 0c0bf1d..ed761de 100644 --- a/ccwl/yaml.scm +++ b/ccwl/yaml.scm @@ -25,12 +25,14 @@ ATOM is a symbol." ((number? atom) (display atom port)) ((string? atom) + ;; TODO: Implement the complete escape logic as per the YAML + ;; specification. ;; Escape string with double quotes if ;; - every character is a digit or period, and the unescaped ;; string can therefore be misinterpreted as a number - ;; - string contains the colon character + ;; - string contains the colon or hyphen characters (if (or (string-every (char-set-union char-set:digit (char-set #\.)) atom) - (string-any #\: atom)) + (string-any (char-set #\: #\-) atom)) (write atom port) (display atom port))) ((boolean? atom) -- cgit v1.2.3