mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/psych/lib/psych/visitors/yaml_tree.rb: quote strings that begin
with non-word characters. Thanks Alex Tambellini! * test/psych/test_yaml.rb: appropriate test case git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38367 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3738ebe15a
commit
8a4cc4e02a
3 changed files with 15 additions and 0 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Fri Dec 14 07:43:44 2012 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||||
|
|
||||||
|
* ext/psych/lib/psych/visitors/yaml_tree.rb: quote strings that begin
|
||||||
|
with non-word characters. Thanks Alex Tambellini!
|
||||||
|
* test/psych/test_yaml.rb: appropriate test case
|
||||||
|
|
||||||
Thu Dec 13 23:14:17 2012 Shugo Maeda <shugo@ruby-lang.org>
|
Thu Dec 13 23:14:17 2012 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
|
|
||||||
* vm_insnhelper.c (vm_call_super_method): a workaround for the
|
* vm_insnhelper.c (vm_call_super_method): a workaround for the
|
||||||
|
|
|
@ -242,6 +242,9 @@ module Psych
|
||||||
elsif o =~ /\n/
|
elsif o =~ /\n/
|
||||||
quote = true
|
quote = true
|
||||||
style = Nodes::Scalar::LITERAL
|
style = Nodes::Scalar::LITERAL
|
||||||
|
elsif o =~ /^\W/
|
||||||
|
quote = true
|
||||||
|
style = Nodes::Scalar::DOUBLE_QUOTED
|
||||||
else
|
else
|
||||||
quote = !(String === @ss.tokenize(o))
|
quote = !(String === @ss.tokenize(o))
|
||||||
plain = !quote
|
plain = !quote
|
||||||
|
|
|
@ -1271,4 +1271,10 @@ EOY
|
||||||
yaml = Psych.dump("multi\nline\nstring")
|
yaml = Psych.dump("multi\nline\nstring")
|
||||||
assert_match("|", yaml)
|
assert_match("|", yaml)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_string_starting_with_non_word_character_uses_double_quotes_without_exclamation_mark
|
||||||
|
yaml = Psych.dump("@123'abc")
|
||||||
|
assert_match("\"", yaml)
|
||||||
|
refute_match("!", yaml)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue