From b800677425e0839eac1014d0a2fe9201cabe3a18 Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 9 Aug 2012 13:49:27 +0000 Subject: merge revision(s) 34972: * 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/branches/ruby_1_9_3@36669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ pack.c | 4 +++- test/ruby/test_pack.rb | 12 ++++++++++++ version.h | 6 +++--- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 16c0a0f36d..2964b117fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Thu Aug 9 22:48:58 2012 NARUSE, Yui + + * 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] + Tue Jul 31 10:36:12 2012 Aaron Patterson * ext/psych/lib/psych.rb: updated to released version. diff --git a/pack.c b/pack.c index 1616a8a638..c9b24b1190 100644 --- a/pack.c +++ b/pack.c @@ -2003,7 +2003,7 @@ pack_unpack(VALUE str, VALUE fmt) case 'M': { VALUE buf = infected_str_new(0, send - s, str); - char *ptr = RSTRING_PTR(buf); + char *ptr = RSTRING_PTR(buf), *ss = s; int c1, c2; while (s < send) { @@ -2022,8 +2022,10 @@ pack_unpack(VALUE str, VALUE fmt) *ptr++ = *s; } s++; + ss = s; } 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); UNPACK_PUSH(buf); } diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb index 6ce16a2aa1..c862215cb4 100644 --- a/test/ruby/test_pack.rb +++ b/test/ruby/test_pack.rb @@ -612,6 +612,18 @@ class TestPack < Test::Unit::TestCase assert_equal([0x100000000], "\220\200\200\200\000".unpack("w"), [0x100000000]) 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 s = "foo" assert_raise(SecurityError) do diff --git a/version.h b/version.h index d06e687ba0..241c8e2e58 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 259 +#define RUBY_PATCHLEVEL 260 -#define RUBY_RELEASE_DATE "2012-08-08" +#define RUBY_RELEASE_DATE "2012-08-09" #define RUBY_RELEASE_YEAR 2012 #define RUBY_RELEASE_MONTH 8 -#define RUBY_RELEASE_DAY 8 +#define RUBY_RELEASE_DAY 9 #include "ruby/version.h" -- cgit v1.2.3