summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-16 11:39:21 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-16 11:39:21 +0000
commitb76d7afffc5f455bbe1b3fac95ed8f2c4a26fe42 (patch)
tree0a244ca3c43c9edd11d37c6a4278f5f43cdbf1c8 /string.c
parentef62988ecce58edc1ffbd6aa70ffd328a03b0923 (diff)
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
Diffstat (limited to 'string.c')
-rw-r--r--string.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/string.c b/string.c
index 9115ad1bde..afdb4db92e 100644
--- a/string.c
+++ b/string.c
@@ -8255,8 +8255,13 @@ 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);