summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--ext/psych/lib/psych/visitors/yaml_tree.rb2
-rw-r--r--test/psych/test_string.rb6
3 files changed, 14 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 8b81ae3..efda708 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Fri Jan 9 07:23:32 2015 Aaron Patterson <aaron@tenderlovemaking.com>
+
+ * ext/psych/lib/psych/visitors/yaml_tree.rb: correctly quote non-ascii
+ letters. Thanks @jirutka for the patch.
+
+ * test/psych/test_string.rb: test for change
+
Fri Jan 9 07:13:55 2015 Aaron Patterson <aaron@tenderlovemaking.com>
* ext/psych/lib/psych/visitors/to_ruby.rb: call `allocate` on hash
diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb
index bedf9d3..3a6bd1d 100644
--- a/ext/psych/lib/psych/visitors/yaml_tree.rb
+++ b/ext/psych/lib/psych/visitors/yaml_tree.rb
@@ -317,7 +317,7 @@ module Psych
tag = 'tag:yaml.org,2002:str'
plain = false
quote = false
- elsif o =~ /^\W[^"]*$/
+ elsif o =~ /^[^[:word:]][^"]*$/
style = Nodes::Scalar::DOUBLE_QUOTED
else
unless String === @ss.tokenize(o)
diff --git a/test/psych/test_string.rb b/test/psych/test_string.rb
index 1ce16fd..26a4e20 100644
--- a/test/psych/test_string.rb
+++ b/test/psych/test_string.rb
@@ -1,3 +1,4 @@
+# encoding: UTF-8
require_relative 'helper'
module Psych
@@ -23,6 +24,11 @@ module Psych
assert_equal 2, Psych.dump(%Q{<%= ENV["PATH"] %>}).count('"')
end
+ def test_no_quotes_when_start_with_non_ascii_character
+ yaml = Psych.dump 'Český non-ASCII'.encode(Encoding::UTF_8)
+ assert_match(/---\s*[^"'!]+$/, yaml)
+ end
+
def test_doublequotes_when_there_is_a_single
yaml = Psych.dump "@123'abc"
assert_match(/---\s*"/, yaml)