diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2017-06-29 15:03:15 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2017-06-29 15:03:15 -0700 |
commit | 8949a47b8cee31e03e21608406ba116adcf74054 (patch) | |
tree | f82f2abc044b5e59bc4a8d01177c615b6f9eb42b /lib/psych/visitors/yaml_tree.rb | |
parent | 0ecb87ce7169f945c9fce55ef3f1b9d859283a73 (diff) | |
download | psych-8949a47b8cee31e03e21608406ba116adcf74054.zip |
Rely on encoding tags to determine if string should be dumped as binary
If a string is tagged as binary, then we should dump it as binary.
Fixes #278
Diffstat (limited to 'lib/psych/visitors/yaml_tree.rb')
-rw-r--r-- | lib/psych/visitors/yaml_tree.rb | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/lib/psych/visitors/yaml_tree.rb b/lib/psych/visitors/yaml_tree.rb index e197a30..03fdc8b 100644 --- a/lib/psych/visitors/yaml_tree.rb +++ b/lib/psych/visitors/yaml_tree.rb @@ -411,15 +411,9 @@ module Psych end private - # FIXME: Remove the index and count checks in Psych 3.0 - NULL = "\x00" - BINARY_RANGE = "\x00-\x7F" - WS_RANGE = "^ -~\t\r\n" def binary? string - (string.encoding == Encoding::ASCII_8BIT && !string.ascii_only?) || - string.index(NULL) || - string.count(BINARY_RANGE, WS_RANGE).fdiv(string.length) > 0.3 + string.encoding == Encoding::ASCII_8BIT && !string.ascii_only? end def visit_array_subclass o |