1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* marshal.c (r_symreal): default to ASCII-8BIT for non-ascii symbols,

otherwise it should be converted to US-ASCII in rb_intern_str() if
  possible.  [ruby-core:43762][Bug #6209]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-03-28 06:06:20 +00:00
parent 113c6d58e7
commit 1521f9331e
3 changed files with 16 additions and 2 deletions

View file

@ -1,3 +1,9 @@
Wed Mar 28 15:06:18 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* marshal.c (r_symreal): default to ASCII-8BIT for non-ascii symbols,
otherwise it should be converted to US-ASCII in rb_intern_str() if
possible. [ruby-core:43762][Bug #6209]
Wed Mar 28 08:44:24 2012 Aaron Patterson <aaron@tenderlovemaking.com>
* ext/psych/lib/psych.rb: updating version to match gem

View file

@ -1161,8 +1161,7 @@ r_symreal(struct load_arg *arg, int ivar)
idx = id2encidx(id, r_object(arg));
}
}
if (idx < 0) idx = rb_usascii_encindex();
rb_enc_associate_index(s, idx);
if (idx > 0) rb_enc_associate_index(s, idx);
id = rb_intern_str(s);
st_insert(arg->symbols, (st_data_t)n, (st_data_t)id);

View file

@ -455,6 +455,15 @@ class TestMarshal < Test::Unit::TestCase
assert_equal(o1, o2)
end
def test_marshal_symbol_ascii8bit
bug6209 = '[ruby-core:43762]'
o1 = "\xff".force_encoding("ASCII-8BIT").intern
m = Marshal.dump(o1)
o2 = nil
assert_nothing_raised(EncodingError, bug6209) {o2 = Marshal.load(m)}
assert_equal(o1, o2, bug6209)
end
class PrivateClass
def initialize(foo)
@foo = foo