mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	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/trunk@57078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									72c1b322c7
								
							
						
					
					
						commit
						201972ac4c
					
				
					 2 changed files with 6 additions and 1 deletions
				
			
		|  | @ -1031,7 +1031,8 @@ rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc) | ||||||
| int | int | ||||||
| rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc) | 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) |     if (e <= p) | ||||||
|         return -1; |         return -1; | ||||||
|     if (rb_enc_asciicompat(enc)) { |     if (rb_enc_asciicompat(enc)) { | ||||||
|  |  | ||||||
|  | @ -567,6 +567,10 @@ class TestRegexp < Test::Unit::TestCase | ||||||
|     assert_equal("\\v", Regexp.quote("\v")) |     assert_equal("\\v", Regexp.quote("\v")) | ||||||
|     assert_equal("\u3042\\t", Regexp.quote("\u3042\t")) |     assert_equal("\u3042\\t", Regexp.quote("\u3042\t")) | ||||||
|     assert_equal("\\t\xff", Regexp.quote("\t" + [0xff].pack("C"))) |     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 |   end | ||||||
| 
 | 
 | ||||||
|   def test_try_convert |   def test_try_convert | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 rhe
						rhe