From c1d4e3fe6440791378470a4177af45f9046d80c7 Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 19 Feb 2018 06:51:53 +0000 Subject: 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]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@62483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_string.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index b0c6e447eb..dd3a0349b5 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -3087,6 +3087,12 @@ CODE 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 -- cgit v1.2.3