mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
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_4@62875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0529216048
commit
681d1e79b7
3 changed files with 8 additions and 1 deletions
1
string.c
1
string.c
|
@ -2451,6 +2451,7 @@ str_substr(VALUE str, long beg, long len, int empty)
|
|||
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;
|
||||
|
|
|
@ -2569,6 +2569,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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#define RUBY_VERSION "2.4.4"
|
||||
#define RUBY_RELEASE_DATE "2018-03-21"
|
||||
#define RUBY_PATCHLEVEL 278
|
||||
#define RUBY_PATCHLEVEL 279
|
||||
|
||||
#define RUBY_RELEASE_YEAR 2018
|
||||
#define RUBY_RELEASE_MONTH 3
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue