summaryrefslogtreecommitdiff
path: root/lib/psych/visitors/yaml_tree.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-09-05 10:40:42 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-09-05 10:40:42 -0700
commit684612c46ee5534904fb811bc3548219fc38ea26 (patch)
tree24afb2e471a77ff703f495f3c75d7c9b93834717 /lib/psych/visitors/yaml_tree.rb
parent02f0498a91b11a3b187812a188bb9e44271f73d7 (diff)
downloadpsych-684612c46ee5534904fb811bc3548219fc38ea26.zip
* ext/psych/lib/psych/visitors/yaml_tree.rb: use double quotes when
strings start with special characters. [Fixes GH-157] https://github.com/tenderlove/psych/issues/157 * test/psych/test_string.rb: test for change. Fixes #157
Diffstat (limited to 'lib/psych/visitors/yaml_tree.rb')
-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 eb1f0d7..f8bece6 100644
--- a/lib/psych/visitors/yaml_tree.rb
+++ b/lib/psych/visitors/yaml_tree.rb
@@ -288,6 +288,8 @@ module Psych
quote = false
elsif o =~ /\n/
style = Nodes::Scalar::LITERAL
+ elsif o =~ /^\W/
+ style = Nodes::Scalar::DOUBLE_QUOTED
else
unless String === @ss.tokenize(o)
style = Nodes::Scalar::SINGLE_QUOTED