diff options
author | Arun Isaac | 2023-11-23 18:22:08 +0000 |
---|---|---|
committer | Arun Isaac | 2023-11-23 19:02:59 +0000 |
commit | d7c5947da0ef130e7a3a33383246bededcb04ee3 (patch) | |
tree | c72b1c76ef30d55439210f1525fb9b71ac285ec3 | |
parent | 9f601fc3f131e82e1ee5791783d330bddde468d2 (diff) | |
download | ccwl-d7c5947da0ef130e7a3a33383246bededcb04ee3.tar.gz ccwl-d7c5947da0ef130e7a3a33383246bededcb04ee3.tar.lz ccwl-d7c5947da0ef130e7a3a33383246bededcb04ee3.zip |
yaml: Escape all indicator characters.
* ccwl/yaml.scm (display-atom): Escape strings if they contain any
indicator character.
-rw-r--r-- | ccwl/yaml.scm | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/ccwl/yaml.scm b/ccwl/yaml.scm index a33a88f..cc27be4 100644 --- a/ccwl/yaml.scm +++ b/ccwl/yaml.scm @@ -1,5 +1,5 @@ ;;; ccwl --- Concise Common Workflow Language -;;; Copyright © 2021 Arun Isaac <arunisaac@systemreboot.net> +;;; Copyright © 2021, 2023 Arun Isaac <arunisaac@systemreboot.net> ;;; ;;; This file is part of ccwl. ;;; @@ -54,10 +54,13 @@ serialized to YAML. Else, return @code{#f}." ;; 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, hyphen or asterisk characters + ;; string can therefore be misinterpreted as a number + ;; - string contains indicator characters as mentioned in the YAML + ;; spec https://yaml.org/spec/1.2.2/#53-indicator-characters (if (or (string-every (char-set-union char-set:digit (char-set #\.)) atom) - (string-any (char-set #\: #\- #\*) atom)) + (string-any (char-set #\- #\? #\: #\, #\[ #\] #\{ #\} #\# #\& + #\* #\! #\| #\> #\' #\" #\% #\@ #\`) + atom)) (write atom port) (display atom port))) ((boolean? atom) |