From e0c6dd91a450a47b701fb0a9d7fd908814651641 Mon Sep 17 00:00:00 2001 From: tenderlove Date: Tue, 29 Oct 2013 18:10:24 +0000 Subject: * ext/psych/lib/psych/visitors/yaml_tree.rb: string subclasses should not be considered to be binary. Fixes Psych / GH 166 https://github.com/tenderlove/psych/issues/166 * test/psych/test_string.rb: test for fix git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/psych/lib/psych/visitors/yaml_tree.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ext') diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb index f8bece64b6..65cbba0658 100644 --- a/ext/psych/lib/psych/visitors/yaml_tree.rb +++ b/ext/psych/lib/psych/visitors/yaml_tree.rb @@ -267,8 +267,7 @@ module Psych def binary? string (string.encoding == Encoding::ASCII_8BIT && !string.ascii_only?) || string.index("\x00") || - string.count("\x00-\x7F", "^ -~\t\r\n").fdiv(string.length) > 0.3 || - string.class != String + string.count("\x00-\x7F", "^ -~\t\r\n").fdiv(string.length) > 0.3 end private :binary? @@ -301,6 +300,8 @@ module Psych if ivars.empty? unless o.class == ::String tag = "!ruby/string:#{o.class}" + plain = false + quote = false end @emitter.scalar str, nil, tag, plain, quote, style else -- cgit v1.2.3