Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit ef4f0418a30902e1fa5237a0561927ea3d479b55 1 parent bdd8e9d
@pck pck authored
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/psych/visitors/yaml_tree.rb
View
5 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?
Please sign in to comment.
Something went wrong with that request. Please try again.