File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -272,7 +272,7 @@ def visit_String o
272
272
tag = 'tag:yaml.org,2002:str'
273
273
plain = false
274
274
quote = false
275
- elsif o == 'y' || o == 'n '
275
+ elsif o == 'y' || o == 'Y' || o == 'n' || o == 'N '
276
276
style = Nodes ::Scalar ::DOUBLE_QUOTED
277
277
elsif @line_width && o . length > @line_width
278
278
style = Nodes ::Scalar ::FOLDED
Original file line number Diff line number Diff line change @@ -24,10 +24,19 @@ def initialize
24
24
# "ambiguity" in the emitted document
25
25
def test_y_is_quoted
26
26
assert_match ( /"y"/ , Psych . dump ( "y" ) )
27
+ assert_match ( /"Y"/ , Psych . dump ( "Y" ) )
27
28
end
28
29
29
30
def test_n_is_quoted
30
31
assert_match ( /"n"/ , Psych . dump ( "n" ) )
32
+ assert_match ( /"N"/ , Psych . dump ( "N" ) )
33
+ end
34
+
35
+ def test_all_yaml_1_1_booleans_are_quoted
36
+ yaml_1_1_booleans = %w[ y Y yes Yes YES n N no No NO true True TRUE false False FALSE on On ON off Off OFF ] # from https://yaml.org/type/bool.html
37
+ yaml_1_1_booleans . each do |boolean |
38
+ assert_match ( /"#{ boolean } "|'#{ boolean } '/ , Psych . dump ( boolean ) )
39
+ end
31
40
end
32
41
33
42
def test_string_with_newline
You can’t perform that action at this time.
0 commit comments