ruby-changes:50367
From: naruse <ko1@a...>
Date: Mon, 19 Feb 2018 15:51:58 +0900 (JST)
Subject: [ruby-changes:50367] naruse:r62483 (ruby_2_5): merge revision(s) 62040: [Backport #14388]
naruse 2018-02-19 15:51:53 +0900 (Mon, 19 Feb 2018) New Revision: 62483 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62483 Log: merge revision(s) 62040: [Backport #14388] string.c: clear substring code range * string.c (str_substr): substring of broken code range string may be valid or broken. patch by tommy (Masahiro Tomita) at [ruby-dev:50430] [Bug #14388]. Modified directories: branches/ruby_2_5/ Modified files: branches/ruby_2_5/string.c branches/ruby_2_5/test/ruby/test_string.rb branches/ruby_2_5/version.h Index: ruby_2_5/string.c =================================================================== --- ruby_2_5/string.c (revision 62482) +++ ruby_2_5/string.c (revision 62483) @@ -2538,6 +2538,7 @@ str_substr(VALUE str, long beg, long len https://github.com/ruby/ruby/blob/trunk/ruby_2_5/string.c#L2538 str2 = str_new_shared(rb_obj_class(str2), str2); RSTRING(str2)->as.heap.ptr += ofs; RSTRING(str2)->as.heap.len = len; + ENC_CODERANGE_CLEAR(str2); } else { if (!len && !empty) return Qnil; Index: ruby_2_5/test/ruby/test_string.rb =================================================================== --- ruby_2_5/test/ruby/test_string.rb (revision 62482) +++ ruby_2_5/test/ruby/test_string.rb (revision 62483) @@ -3087,6 +3087,12 @@ CODE https://github.com/ruby/ruby/blob/trunk/ruby_2_5/test/ruby/test_string.rb#L3087 assert_equal("\u3042", "\u3042\u3043".chr) assert_equal('', ''.chr) end + + def test_substr_code_range + data = "\xff" + "a"*200 + assert_not_predicate(data, :valid_encoding?) + assert_predicate(data[100..-1], :valid_encoding?) + end end class TestString2 < TestString Index: ruby_2_5/version.h =================================================================== --- ruby_2_5/version.h (revision 62482) +++ ruby_2_5/version.h (revision 62483) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_5/version.h#L1 #define RUBY_VERSION "2.5.0" #define RUBY_RELEASE_DATE "2018-02-19" -#define RUBY_PATCHLEVEL 23 +#define RUBY_PATCHLEVEL 24 #define RUBY_RELEASE_YEAR 2018 #define RUBY_RELEASE_MONTH 2 Index: ruby_2_5 =================================================================== --- ruby_2_5 (revision 62482) +++ ruby_2_5 (revision 62483) Property changes on: ruby_2_5 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r62040 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/