From b76d7afffc5f455bbe1b3fac95ed8f2c4a26fe42 Mon Sep 17 00:00:00 2001 From: usa Date: Tue, 16 Aug 2016 11:39:21 +0000 Subject: merge revision(s) 55181: [Backport #12431] * transcode.c (str_transcode0): scrub in the given encoding when the source encoding is given, not in the encoding of the receiver. [ruby-core:75732] [Bug #12431] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@55936 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- string.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'string.c') diff --git a/string.c b/string.c index 9115ad1bde..afdb4db92e 100644 --- a/string.c +++ b/string.c @@ -8254,9 +8254,14 @@ str_compat_and_valid(VALUE str, rb_encoding *enc) */ VALUE rb_str_scrub(VALUE str, VALUE repl) +{ + return rb_enc_str_scrub(STR_ENC_GET(str), str, repl); +} + +VALUE +rb_enc_str_scrub(rb_encoding *enc, VALUE str, VALUE repl) { int cr = ENC_CODERANGE(str); - rb_encoding *enc; int encidx; VALUE buf = Qnil; const char *rep; @@ -8266,7 +8271,6 @@ rb_str_scrub(VALUE str, VALUE repl) if (cr == ENC_CODERANGE_7BIT || cr == ENC_CODERANGE_VALID) return Qnil; - enc = STR_ENC_GET(str); if (!NIL_P(repl)) { repl = str_compat_and_valid(repl, enc); tainted = OBJ_TAINTED_RAW(repl); -- cgit v1.2.3