diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-29 11:11:10 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-29 11:11:10 -0700 |
commit | 2ffd057a29dc4fdec0f11697af260c4cfb4e3d84 (patch) | |
tree | b3717c2dfd19d0bfddfac819e2fe511c0f25e0ea /lib/psych/visitors/yaml_tree.rb | |
parent | 24b0860c85d4cb9b84876fc426c0fbff8ba36916 (diff) | |
download | psych-2ffd057a29dc4fdec0f11697af260c4cfb4e3d84.zip |
* 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
Fixes #166
Diffstat (limited to 'lib/psych/visitors/yaml_tree.rb')
-rw-r--r-- | lib/psych/visitors/yaml_tree.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/psych/visitors/yaml_tree.rb b/lib/psych/visitors/yaml_tree.rb index f8bece6..65cbba0 100644 --- a/lib/psych/visitors/yaml_tree.rb +++ b/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 |