summaryrefslogtreecommitdiff
path: root/ext/psych
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-09 19:26:36 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-09 19:26:36 +0000
commitac8b1869c0b80fd948a6a50d2a737123b5fa5bd2 (patch)
tree0c9d08c05d1b0a6c2c2c874268cc0d5a14589b3d /ext/psych
parent113c81219de64c9e7d40b113b6a6d98d882e4d9f (diff)
* ext/psych/lib/psych/visitors/yaml_tree.rb: ascii only binary strings
will be dumped as unicode. Thanks Paul Kunysch! * test/psych/test_string.rb: appropriate test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38753 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/psych')
-rw-r--r--ext/psych/lib/psych/visitors/yaml_tree.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb
index 5efb654aab..ce40a17eb3 100644
--- a/ext/psych/lib/psych/visitors/yaml_tree.rb
+++ b/ext/psych/lib/psych/visitors/yaml_tree.rb
@@ -221,9 +221,10 @@ module Psych
end
def binary? string
- string.encoding == Encoding::ASCII_8BIT ||
+ (string.encoding == Encoding::ASCII_8BIT && !string.ascii_only?) ||
string.index("\x00") ||
- string.count("\x00-\x7F", "^ -~\t\r\n").fdiv(string.length) > 0.3
+ string.count("\x00-\x7F", "^ -~\t\r\n").fdiv(string.length) > 0.3 ||
+ string.class != String
end
private :binary?