Bug #6652 ยป 0001-compatible-marshal-loader.patch
ext/date/date_core.c | ||
---|---|---|
INT2FIX(m_of(dat)),
|
||
DBL2NUM(m_sg(dat)));
|
||
if (FL_TEST(self, FL_EXIVAR)) {
|
||
rb_copy_generic_ivar(a, self);
|
||
FL_SET(a, FL_EXIVAR);
|
||
}
|
||
return a;
|
||
}
|
||
... | ... | |
return self;
|
||
}
|
||
/* :nodoc: */
|
||
static VALUE
|
||
d_lite_old_load(VALUE klass, VALUE s)
|
||
{
|
||
VALUE data = rb_marshal_load(s);
|
||
VALUE self = rb_obj_alloc(klass);
|
||
Check_Type(data, T_ARRAY);
|
||
if (RARRAY_LEN(data) == 2) {
|
||
const VALUE *ptr = RARRAY_PTR(data);
|
||
data = rb_ary_new3(3, ptr[0], INT2FIX(0), ptr[1]);
|
||
}
|
||
return d_lite_marshal_load(self, data);
|
||
}
|
||
/* datetime */
|
||
... | ... | |
#endif
|
||
rb_define_method(cDate, "marshal_dump", d_lite_marshal_dump, 0);
|
||
rb_define_method(cDate, "marshal_load", d_lite_marshal_load, 1);
|
||
rb_define_singleton_method(cDate, "_load", d_lite_old_load, 1);
|
||
/* datetime */
|
||
test/date/test_date_marshal.rb | ||
---|---|---|
assert_raise(RuntimeError){d.marshal_load(a)}
|
||
end
|
||
def test_marshal_old
|
||
data = "\004\bu:\tDate=\004\b[\bo:\rRational\a:\017@numeratori\003%\275J:\021" \
|
||
"@denominatori\ai\000i\003\031\025#"
|
||
assert_equal(Date.new(1993, 2, 24), Marshal.load(data))
|
||
data = "\004\bu:\rDateTimeC\004\b[\bo:\rRational\a:\017@numeratorl+\bK\355B\024\003\000:\021" \
|
||
"@denominatori\002\030\025i\000i\003\031\025#"
|
||
assert_equal(DateTime.new(1993, 2, 24, 12, 34, 56), Marshal.load(data))
|
||
end
|
||
end
|