Permalink
Browse files

Changed Psych::Visitors::YAMLTree.binary?(string).

* A human-readable representation can be used for ascii_only 8bit-encoded strings.
* String subclasses are binary, even if they are character-encoded.
  • Loading branch information...
pck committed Jan 6, 2013
1 parent bdd8e9d commit ef4f0418a30902e1fa5237a0561927ea3d479b55
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/psych/visitors/yaml_tree.rb
@@ -221,9 +221,10 @@ def visit_BigDecimal o
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?

0 comments on commit ef4f041

Please sign in to comment.