summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-01 11:53:59 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-01 11:53:59 +0000
commite7fac351c2d46696a5de85710e765327e8346cce (patch)
tree78ed711f4c38aad4a36022ab9e044e2af989c1d7
parent21ea356a42724847f3066d68ad246639fb374927 (diff)
string.c: fix typo
* string.c (rb_str_scrub): fix typo, should yield invalid byte sequence to be scrubbed. reported by znz at IRC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--string.c2
-rw-r--r--test/ruby/test_m17n.rb3
3 files changed, 9 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 8fa08a2cd7..0711bfa1fc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Nov 1 20:53:56 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * string.c (rb_str_scrub): fix typo, should yield invalid byte
+ sequence to be scrubbed. reported by znz at IRC.
+
Fri Nov 1 17:25:30 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* gc.c (is_live_object): finalizer may not run because of lazy-sweep.
diff --git a/string.c b/string.c
index 191f846d36..dbfce96788 100644
--- a/string.c
+++ b/string.c
@@ -8069,7 +8069,7 @@ rb_str_scrub(VALUE str, VALUE repl)
if (!rep7bit_p) cr = ENC_CODERANGE_VALID;
}
else {
- repl = rb_yield(rb_enc_str_new(p1, clen, enc));
+ repl = rb_yield(rb_enc_str_new(p, clen, enc));
repl = str_compat_and_valid(repl, enc);
rb_str_buf_cat(buf, RSTRING_PTR(repl), RSTRING_LEN(repl));
if (ENC_CODERANGE(repl) == ENC_CODERANGE_VALID)
diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb
index 183df6e13e..f23ba9cb9b 100644
--- a/test/ruby/test_m17n.rb
+++ b/test/ruby/test_m17n.rb
@@ -1524,6 +1524,9 @@ 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("\x81", u("a\x81").scrub {|c| break c})
+ assert_raise(ArgumentError) {u("a\x81").scrub {|c| c}}
+
assert_equal("\uFFFD\u3042".encode("UTF-16BE"),
"\xD8\x00\x30\x42".force_encoding(Encoding::UTF_16BE).
scrub)