aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2021-03-07 03:36:52 +0530
committerArun Isaac2021-03-07 03:53:46 +0530
commit23789db7ed409ccafc079d5fe9e9d0c32b66abe5 (patch)
treef2912ea965686619750a61a9b641eddc71cda5f1
parentd57b1222e54a1e41ddd32fc759cd5d26b665b6cb (diff)
downloadccwl-23789db7ed409ccafc079d5fe9e9d0c32b66abe5.tar.gz
ccwl-23789db7ed409ccafc079d5fe9e9d0c32b66abe5.tar.lz
ccwl-23789db7ed409ccafc079d5fe9e9d0c32b66abe5.zip
Escape YAML strings that contain the hyphen character.
* ccwl/yaml.scm (display-atom): Escape string if it contains the hyphen character.
-rw-r--r--ccwl/yaml.scm6
1 files 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)