diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-01-11 02:18:45 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-01-11 02:18:45 +0000 |
commit | 32f7ad36130eb97df6cae2c9e908b8556134e60a (patch) | |
tree | 1c228194956782b1c36da6487095315bfbef7c4b | |
parent | c1a8666faf5a95e9bb9b1acb8f2fa3f1b9e46152 (diff) | |
download | ruby-32f7ad36130eb97df6cae2c9e908b8556134e60a.tar.gz |
string.c: yield invalid part
* string.c (rb_enc_str_scrub): yield the invalid part only with
ASCII-incompatible. [ruby-core:79039] [Bug #13120]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | string.c | 2 | ||||
-rw-r--r-- | test/ruby/test_m17n.rb | 6 |
2 files changed, 4 insertions, 4 deletions
@@ -9400,7 +9400,7 @@ rb_enc_str_scrub(rb_encoding *enc, VALUE str, VALUE repl) rb_str_buf_cat(buf, rep, replen); } else { - repl = rb_yield(rb_enc_str_new(p, e-p, enc)); + repl = rb_yield(rb_enc_str_new(p, clen, enc)); repl = str_compat_and_valid(repl, enc); tainted |= OBJ_TAINTED_RAW(repl); rb_str_buf_cat(buf, RSTRING_PTR(repl), RSTRING_LEN(repl)); diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb index c610f71216..44f19254dc 100644 --- a/test/ruby/test_m17n.rb +++ b/test/ruby/test_m17n.rb @@ -1623,7 +1623,7 @@ class TestM17N < Test::Unit::TestCase assert_raise(ArgumentError){ u("\xE3\x81\x82\xE3\x81\x82\xE3\x81").scrub{u("\x81")} } assert_equal(e("\xA4\xA2\xA2\xAE"), e("\xA4\xA2\xA4").scrub{e("\xA2\xAE")}) - assert_equal(u("\x81"), u("a\x81").scrub {|c| break c}) + assert_equal(u("\x81"), u("a\x81c").scrub {|c| break c}) assert_raise(ArgumentError) {u("a\x81").scrub {|c| c}} end @@ -1641,8 +1641,8 @@ class TestM17N < Test::Unit::TestCase "\xff".force_encoding(Encoding::UTF_32LE). scrub) c = nil - assert_equal("?".encode(Encoding::UTF_16LE), - "\x00\xD8".force_encoding(Encoding::UTF_16LE). + assert_equal("?\u3042".encode(Encoding::UTF_16LE), + "\x00\xD8\x42\x30".force_encoding(Encoding::UTF_16LE). scrub {|e| c = e; "?".encode(Encoding::UTF_16LE)}) assert_equal("\x00\xD8".force_encoding(Encoding::UTF_16LE), c) end |