summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2021-08-04 09:27:04 -0700
committerAaron Patterson <tenderlove@ruby-lang.org>2021-08-04 09:27:04 -0700
commit6a1c30634e61967f3d8133b3181b9f301ff7f550 (patch)
treeecf1ca8343e71e2c804c06222c3d68ce993257a5 /lib
parent0be49786edf40b9956da0693d112f770588424e4 (diff)
downloadpsych-6a1c30634e61967f3d8133b3181b9f301ff7f550.tar.gz
Add quotes to the strings "y" and "n"
'y' and 'n' are kind of ambiguous. Syck treated y and n literals in YAML documents as strings. But this is not what the YAML 1.1 spec says. YAML 1.1 says they should be treated as booleans. When we're dumping documents, we know it's a string, so adding quotes will eliminate the "ambiguity" in the emitted document Fixes #443
Diffstat (limited to 'lib')
-rw-r--r--lib/psych/visitors/yaml_tree.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/psych/visitors/yaml_tree.rb b/lib/psych/visitors/yaml_tree.rb
index 05748dd..2eee4d3 100644
--- a/lib/psych/visitors/yaml_tree.rb
+++ b/lib/psych/visitors/yaml_tree.rb
@@ -272,6 +272,8 @@ module Psych
tag = 'tag:yaml.org,2002:str'
plain = false
quote = false
+ elsif o == 'y' || o == 'n'
+ style = Nodes::Scalar::DOUBLE_QUOTED
elsif @line_width && o.length > @line_width
style = Nodes::Scalar::FOLDED
elsif o =~ /^[^[:word:]][^"]*$/