diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-01-16 19:31:25 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-01-16 19:31:25 +0000 |
commit | f327b5e23ce39b3dbe9ada818232731d7c70e39b (patch) | |
tree | 56cb8f32d20a0ba69af486e80cc099e0f31ea3c3 | |
parent | 8cc9818463fc72c08118ae83cd6a1d8c91106d86 (diff) |
merge revision(s) 57078: [Backport #13034]
encoding.c: handle needmore error from rb_enc_precise_mbclen()
rb_enc_ascget() erroneously reports success even if the given byte
sequence is incomplete, for non-ASCII compatible encoding strings.
rb_enc_precise_mbclen() may return a negative value on error, and thus
rb_enc_ascget() must not store the return value in 'unsigned int';
otherwise the subsequent MBCLEN_CHARFOUND_P() check won't catch the
error. [ruby-core:78646] [Bug #13034]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@57348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | encoding.c | 3 | ||||
-rw-r--r-- | test/ruby/test_regexp.rb | 4 | ||||
-rw-r--r-- | version.h | 2 |
3 files changed, 7 insertions, 2 deletions
diff --git a/encoding.c b/encoding.c index 474dd26b8d..f2f2b55c6d 100644 --- a/encoding.c +++ b/encoding.c @@ -1031,7 +1031,8 @@ rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc) int rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc) { - unsigned int c, l; + unsigned int c; + int l; if (e <= p) return -1; if (rb_enc_asciicompat(enc)) { diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index bd10ad5395..5f60ba6f2c 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -493,6 +493,10 @@ class TestRegexp < Test::Unit::TestCase assert_equal("\\v", Regexp.quote("\v")) assert_equal("\u3042\\t", Regexp.quote("\u3042\t")) assert_equal("\\t\xff", Regexp.quote("\t" + [0xff].pack("C"))) + + bug13034 = '[ruby-core:78646] [Bug #13034]' + str = "\x00".force_encoding("UTF-16BE") + assert_equal(str, Regexp.quote(str), bug13034) end def test_try_convert @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.3.3" #define RUBY_RELEASE_DATE "2017-01-17" -#define RUBY_PATCHLEVEL 232 +#define RUBY_PATCHLEVEL 233 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 1 |