ruby-changes:37636
From: naruse <ko1@a...>
Date: Tue, 24 Feb 2015 16:37:14 +0900 (JST)
Subject: [ruby-changes:37636] naruse:r49717 (ruby_2_2): merge revision(s) 49695: [Backport #10886]
naruse 2015-02-24 16:36:55 +0900 (Tue, 24 Feb 2015) New Revision: 49717 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49717 Log: merge revision(s) 49695: [Backport #10886] * string.c (rb_str_split_m): raise ArgumentError at broken string not RegexpError, as Regexp is not involved in. [ruby-core:68229] [Bug #10886] Modified directories: branches/ruby_2_2/ Modified files: branches/ruby_2_2/ChangeLog branches/ruby_2_2/string.c branches/ruby_2_2/test/ruby/test_string.rb branches/ruby_2_2/version.h Index: ruby_2_2/ChangeLog =================================================================== --- ruby_2_2/ChangeLog (revision 49716) +++ ruby_2_2/ChangeLog (revision 49717) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1 +Tue Feb 24 16:31:53 2015 Nobuyoshi Nakada <nobu@r...> + + * string.c (rb_str_split_m): raise ArgumentError at broken string + not RegexpError, as Regexp is not involved in. + [ruby-core:68229] [Bug #10886] + Tue Feb 24 14:00:46 2015 Koichi Sasada <ko1@a...> * gc.c (rb_objspace_call_finalizer): control GC execution during Index: ruby_2_2/string.c =================================================================== --- ruby_2_2/string.c (revision 49716) +++ ruby_2_2/string.c (revision 49717) @@ -6384,10 +6384,11 @@ rb_str_split_m(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/ruby_2_2/string.c#L6384 } else { fs_set: - spat = get_pat_quoted(spat, 1); + spat = get_pat_quoted(spat, 0); if (BUILTIN_TYPE(spat) == T_STRING) { rb_encoding *enc2 = STR_ENC_GET(spat); + mustnot_broken(spat); split_type = string; if (RSTRING_LEN(spat) == 0) { /* Special case - split into chars */ @@ -6482,7 +6483,6 @@ rb_str_split_m(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/ruby_2_2/string.c#L6483 long slen = RSTRING_LEN(spat); mustnot_broken(str); - mustnot_broken(spat); enc = rb_enc_check(str, spat); while (ptr < eptr && (end = rb_memsearch(sptr, slen, ptr, eptr - ptr, enc)) >= 0) { Index: ruby_2_2/version.h =================================================================== --- ruby_2_2/version.h (revision 49716) +++ ruby_2_2/version.h (revision 49717) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1 #define RUBY_VERSION "2.2.0" #define RUBY_RELEASE_DATE "2015-02-24" -#define RUBY_PATCHLEVEL 79 +#define RUBY_PATCHLEVEL 80 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 2 Index: ruby_2_2/test/ruby/test_string.rb =================================================================== --- ruby_2_2/test/ruby/test_string.rb (revision 49716) +++ ruby_2_2/test/ruby/test_string.rb (revision 49717) @@ -1345,14 +1345,18 @@ class TestString < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_string.rb#L1345 assert_equal([], "".split(//, 1)) assert_equal("[2, 3]", [1,2,3].slice!(1,10000).inspect, "moved from btest/knownbug") + end + def test_split_encoding bug6206 = '[ruby-dev:45441]' Encoding.list.each do |enc| next unless enc.ascii_compatible? s = S("a:".force_encoding(enc)) assert_equal([enc]*2, s.split(":", 2).map(&:encoding), bug6206) end + end + def test_split_wchar bug8642 = '[ruby-core:56036] [Bug #8642]' [ Encoding::UTF_16BE, Encoding::UTF_16LE, @@ -1365,6 +1369,20 @@ class TestString < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_string.rb#L1369 end end + def test_split_invalid_sequence + bug10886 = '[ruby-core:68229] [Bug #10886]' + broken = S("\xa1".force_encoding("utf-8")) + assert_raise(ArgumentError, bug10886) { + S("a,b").split(broken) + } + end + + def test_split_invalid_argument + assert_raise(TypeError) { + S("a,b").split(BasicObject.new) + } + end + def test_squeeze assert_equal(S("abc"), S("aaabbbbccc").squeeze) assert_equal(S("aa bb cc"), S("aa bb cc").squeeze(S(" "))) Property changes on: ruby_2_2 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r49695 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/