[前][次][番号順一覧][スレッド一覧]

ruby-changes:43832

From: nagachika <ko1@a...>
Date: Tue, 16 Aug 2016 04:02:17 +0900 (JST)
Subject: [ruby-changes:43832] nagachika:r55905 (ruby_2_3): merge revision(s) 55181: [Backport #12431]

nagachika	2016-08-16 04:02:10 +0900 (Tue, 16 Aug 2016)

  New Revision: 55905

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55905

  Log:
    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]

  Modified directories:
    branches/ruby_2_3/
  Modified files:
    branches/ruby_2_3/ChangeLog
    branches/ruby_2_3/internal.h
    branches/ruby_2_3/string.c
    branches/ruby_2_3/test/ruby/test_transcode.rb
    branches/ruby_2_3/transcode.c
    branches/ruby_2_3/version.h
Index: ruby_2_3/string.c
===================================================================
--- ruby_2_3/string.c	(revision 55904)
+++ ruby_2_3/string.c	(revision 55905)
@@ -8675,8 +8675,13 @@ str_compat_and_valid(VALUE str, rb_encod https://github.com/ruby/ruby/blob/trunk/ruby_2_3/string.c#L8675
 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) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/string.c#L8691
     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);
Index: ruby_2_3/version.h
===================================================================
--- ruby_2_3/version.h	(revision 55904)
+++ ruby_2_3/version.h	(revision 55905)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1
 #define RUBY_VERSION "2.3.2"
 #define RUBY_RELEASE_DATE "2016-08-16"
-#define RUBY_PATCHLEVEL 155
+#define RUBY_PATCHLEVEL 156
 
 #define RUBY_RELEASE_YEAR 2016
 #define RUBY_RELEASE_MONTH 8
Index: ruby_2_3/test/ruby/test_transcode.rb
===================================================================
--- ruby_2_3/test/ruby/test_transcode.rb	(revision 55904)
+++ ruby_2_3/test/ruby/test_transcode.rb	(revision 55905)
@@ -1213,6 +1213,9 @@ class TestTranscode < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_transcode.rb#L1213
   def test_invalid_replace_string
     assert_equal("a<x>A", "a\x80A".encode("us-ascii", "euc-jp", :invalid=>:replace, :replace=>"<x>"))
     assert_equal("a<x>A", "a\x80A".encode("us-ascii", "euc-jis-2004", :invalid=>:replace, :replace=>"<x>"))
+    s = "abcd\u{c1}"
+    r = s.b.encode("UTF-8", "UTF-8", invalid: :replace, replace: "\u{fffd}")
+    assert_equal(s, r)
   end
 
   def test_undef_replace
Index: ruby_2_3/ChangeLog
===================================================================
--- ruby_2_3/ChangeLog	(revision 55904)
+++ ruby_2_3/ChangeLog	(revision 55905)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1
+Tue Aug 16 03:51:59 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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]
+
 Tue Aug 16 03:41:21 2016  Kazuki Yamaguchi  <k@r...>
 
 	* ext/openssl/ossl_pkey_dh.c (ossl_dh_compute_key): Check that the DH
Index: ruby_2_3/transcode.c
===================================================================
--- ruby_2_3/transcode.c	(revision 55904)
+++ ruby_2_3/transcode.c	(revision 55905)
@@ -2700,7 +2700,7 @@ str_transcode0(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/ruby_2_3/transcode.c#L2700
 		if (!NIL_P(ecopts)) {
 		    rep = rb_hash_aref(ecopts, sym_replace);
 		}
-		dest = rb_str_scrub(str, rep);
+		dest = rb_enc_str_scrub(senc, str, rep);
 		if (NIL_P(dest)) dest = str;
 		*self = dest;
 		return dencidx;
Index: ruby_2_3/internal.h
===================================================================
--- ruby_2_3/internal.h	(revision 55904)
+++ ruby_2_3/internal.h	(revision 55905)
@@ -1129,6 +1129,7 @@ VALUE rb_str_locktmp_ensure(VALUE str, V https://github.com/ruby/ruby/blob/trunk/ruby_2_3/internal.h#L1129
 VALUE rb_external_str_with_enc(VALUE str, rb_encoding *eenc);
 VALUE rb_str_cat_conv_enc_opts(VALUE newstr, long ofs, const char *ptr, long len,
 			       rb_encoding *from, int ecflags, VALUE ecopts);
+VALUE rb_enc_str_scrub(rb_encoding *enc, VALUE str, VALUE repl);
 #endif
 #define STR_NOEMBED      FL_USER1
 #define STR_SHARED       FL_USER2 /* = ELTS_SHARED */

Property changes on: ruby_2_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r55181


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]