diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/psych/lib/psych/visitors/yaml_tree.rb | 5 |
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? |