* 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 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
887ff70f23
commit
e0c6dd91a4
@ -1,3 +1,11 @@
|
|||||||
|
Wed Oct 30 03:08:24 2013 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||||
|
|
||||||
|
* 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
|
||||||
|
|
||||||
Tue Oct 29 23:01:18 2013 Masaki Matsushita <glass.saga@gmail.com>
|
Tue Oct 29 23:01:18 2013 Masaki Matsushita <glass.saga@gmail.com>
|
||||||
|
|
||||||
* array.c (rb_ary_zip): some refactoring.
|
* array.c (rb_ary_zip): some refactoring.
|
||||||
|
@ -267,8 +267,7 @@ module Psych
|
|||||||
def binary? string
|
def binary? string
|
||||||
(string.encoding == Encoding::ASCII_8BIT && !string.ascii_only?) ||
|
(string.encoding == Encoding::ASCII_8BIT && !string.ascii_only?) ||
|
||||||
string.index("\x00") ||
|
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
|
end
|
||||||
private :binary?
|
private :binary?
|
||||||
|
|
||||||
@ -301,6 +300,8 @@ module Psych
|
|||||||
if ivars.empty?
|
if ivars.empty?
|
||||||
unless o.class == ::String
|
unless o.class == ::String
|
||||||
tag = "!ruby/string:#{o.class}"
|
tag = "!ruby/string:#{o.class}"
|
||||||
|
plain = false
|
||||||
|
quote = false
|
||||||
end
|
end
|
||||||
@emitter.scalar str, nil, tag, plain, quote, style
|
@emitter.scalar str, nil, tag, plain, quote, style
|
||||||
else
|
else
|
||||||
|
@ -20,6 +20,11 @@ module Psych
|
|||||||
assert_match(/---\s*"/, yaml)
|
assert_match(/---\s*"/, yaml)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_cycle_x
|
||||||
|
str = X.new 'abc'
|
||||||
|
assert_cycle str
|
||||||
|
end
|
||||||
|
|
||||||
def test_dash_dot
|
def test_dash_dot
|
||||||
assert_cycle '-.'
|
assert_cycle '-.'
|
||||||
assert_cycle '+.'
|
assert_cycle '+.'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user