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_3@62946 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
dc4e42b9ad
commit
aaf1f031be
4 changed files with 15 additions and 1 deletions
|
@ -1,3 +1,10 @@
|
|||
Thu Mar 28 14:50:52 2018 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
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 [Bug #14388].
|
||||
|
||||
Thu Mar 28 14:48:13 2018 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
win32.c: memcpy instead of strlcpy
|
||||
|
|
1
string.c
1
string.c
|
@ -2287,6 +2287,7 @@ rb_str_substr(VALUE str, long beg, long len)
|
|||
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 {
|
||||
str2 = rb_str_new_with_class(str, p, len);
|
||||
|
|
|
@ -2330,6 +2330,12 @@ class TestString < Test::Unit::TestCase
|
|||
assert_not_equal(str.object_id, (+str).object_id)
|
||||
assert_equal(str.object_id, (-str).object_id)
|
||||
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.3.7"
|
||||
#define RUBY_RELEASE_DATE "2018-03-28"
|
||||
#define RUBY_PATCHLEVEL 442
|
||||
#define RUBY_PATCHLEVEL 443
|
||||
|
||||
#define RUBY_RELEASE_YEAR 2018
|
||||
#define RUBY_RELEASE_MONTH 3
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue