mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
marshal.c: class name encoding
* marshal.c (r_object0): preserve the encoding of the class name in an error message, in the case of USRMARSHAL without marshal_load method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0ea135d177
commit
982a9d8e91
2 changed files with 15 additions and 3 deletions
|
@ -1837,7 +1837,8 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
|
||||||
|
|
||||||
case TYPE_USRMARSHAL:
|
case TYPE_USRMARSHAL:
|
||||||
{
|
{
|
||||||
VALUE klass = path2class(r_unique(arg));
|
VALUE name = r_unique(arg);
|
||||||
|
VALUE klass = path2class(name);
|
||||||
VALUE oldclass = 0;
|
VALUE oldclass = 0;
|
||||||
VALUE data;
|
VALUE data;
|
||||||
|
|
||||||
|
@ -1847,8 +1848,8 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
|
||||||
append_extmod(v, extmod);
|
append_extmod(v, extmod);
|
||||||
}
|
}
|
||||||
if (!rb_obj_respond_to(v, s_mload, TRUE)) {
|
if (!rb_obj_respond_to(v, s_mload, TRUE)) {
|
||||||
rb_raise(rb_eTypeError, "instance of %s needs to have method `marshal_load'",
|
rb_raise(rb_eTypeError, "instance of %"PRIsVALUE" needs to have method `marshal_load'",
|
||||||
rb_class2name(klass));
|
name);
|
||||||
}
|
}
|
||||||
v = r_entry(v, arg);
|
v = r_entry(v, arg);
|
||||||
data = r_object(arg);
|
data = r_object(arg);
|
||||||
|
|
|
@ -684,4 +684,15 @@ class TestMarshal < Test::Unit::TestCase
|
||||||
Marshal.load(d)
|
Marshal.load(d)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_unloadable_usrmarshal
|
||||||
|
c = eval("class UsrMarshal\u{23F0 23F3}<Time;self;end")
|
||||||
|
c.class_eval {
|
||||||
|
alias marshal_dump _dump
|
||||||
|
}
|
||||||
|
d = Marshal.dump(c.new)
|
||||||
|
assert_raise_with_message(TypeError, /UsrMarshal\u{23F0 23F3}/) {
|
||||||
|
Marshal.load(d)
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue