* pack.c (pack_unpack): when unpack('M') occurs an illegal byte
sequence, output the "=" character and the following character in the decoded data without any transformation. [ruby-dev:44875] [Bug #5635] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34972 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4d8d3184d1
commit
b7df3e9f4e
@ -1,3 +1,10 @@
|
|||||||
|
Sun Mar 11 23:57:29 2012 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
|
* pack.c (pack_unpack): when unpack('M') occurs an illegal byte
|
||||||
|
sequence, output the "=" character and the following character in
|
||||||
|
the decoded data without any transformation.
|
||||||
|
[ruby-dev:44875] [Bug #5635]
|
||||||
|
|
||||||
Sun Mar 11 22:32:43 2012 NARUSE, Yui <naruse@ruby-lang.org>
|
Sun Mar 11 22:32:43 2012 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* ext/json: Merge 164a75c8bd2007d32c4d7665d53140d8fc126dcd.
|
* ext/json: Merge 164a75c8bd2007d32c4d7665d53140d8fc126dcd.
|
||||||
|
4
pack.c
4
pack.c
@ -1991,7 +1991,7 @@ pack_unpack(VALUE str, VALUE fmt)
|
|||||||
case 'M':
|
case 'M':
|
||||||
{
|
{
|
||||||
VALUE buf = infected_str_new(0, send - s, str);
|
VALUE buf = infected_str_new(0, send - s, str);
|
||||||
char *ptr = RSTRING_PTR(buf);
|
char *ptr = RSTRING_PTR(buf), *ss = s;
|
||||||
int c1, c2;
|
int c1, c2;
|
||||||
|
|
||||||
while (s < send) {
|
while (s < send) {
|
||||||
@ -2010,8 +2010,10 @@ pack_unpack(VALUE str, VALUE fmt)
|
|||||||
*ptr++ = *s;
|
*ptr++ = *s;
|
||||||
}
|
}
|
||||||
s++;
|
s++;
|
||||||
|
ss = s;
|
||||||
}
|
}
|
||||||
rb_str_set_len(buf, ptr - RSTRING_PTR(buf));
|
rb_str_set_len(buf, ptr - RSTRING_PTR(buf));
|
||||||
|
rb_str_buf_cat(buf, ss, send-ss);
|
||||||
ENCODING_CODERANGE_SET(buf, rb_ascii8bit_encindex(), ENC_CODERANGE_VALID);
|
ENCODING_CODERANGE_SET(buf, rb_ascii8bit_encindex(), ENC_CODERANGE_VALID);
|
||||||
UNPACK_PUSH(buf);
|
UNPACK_PUSH(buf);
|
||||||
}
|
}
|
||||||
|
@ -612,6 +612,18 @@ class TestPack < Test::Unit::TestCase
|
|||||||
assert_equal([0x100000000], "\220\200\200\200\000".unpack("w"), [0x100000000])
|
assert_equal([0x100000000], "\220\200\200\200\000".unpack("w"), [0x100000000])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def test_pack_unpack_M
|
||||||
|
assert_equal(["pre123after"], "pre=31=32=33after".unpack("M"))
|
||||||
|
assert_equal(["preafter"], "pre=\nafter".unpack("M"))
|
||||||
|
assert_equal(["preafter"], "pre=\r\nafter".unpack("M"))
|
||||||
|
assert_equal(["pre="], "pre=".unpack("M"))
|
||||||
|
assert_equal(["pre=\r"], "pre=\r".unpack("M"))
|
||||||
|
assert_equal(["pre=hoge"], "pre=hoge".unpack("M"))
|
||||||
|
assert_equal(["pre==31after"], "pre==31after".unpack("M"))
|
||||||
|
assert_equal(["pre===31after"], "pre===31after".unpack("M"))
|
||||||
|
end
|
||||||
|
|
||||||
def test_modify_under_safe4
|
def test_modify_under_safe4
|
||||||
s = "foo"
|
s = "foo"
|
||||||
assert_raise(SecurityError) do
|
assert_raise(SecurityError) do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user