diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-08-15 19:02:10 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-08-15 19:02:10 +0000 |
commit | 9b71251e1e8f86972df2c0eda7c4209c5da7488a (patch) | |
tree | b6c48f35a415eccd80f4dfb59b0572caf7d617aa /string.c | |
parent | 243d224f285c8a4a5e4db344e2f4d4023cf8d2e9 (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_3@55905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -8675,8 +8675,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; @@ -8686,7 +8691,6 @@ rb_str_scrub(VALUE str, VALUE repl) if (ENC_CODERANGE_CLEAN_P(cr)) return Qnil; - enc = STR_ENC_GET(str); if (!NIL_P(repl)) { repl = str_compat_and_valid(repl, enc); tainted = OBJ_TAINTED_RAW(repl); |