mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	re.c: append excape sequence as-is
* re.c (unescape_nonascii): append excape sequence as-is not unescaped character, to get rid of unexpected meta-character. [ruby-core:67193] [Bug #10670] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									d1e65737f6
								
							
						
					
					
						commit
						316210b80b
					
				
					 3 changed files with 17 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,9 @@
 | 
			
		|||
Mon Dec 29 18:58:46 2014  Nobuyoshi Nakada  <nobu@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* re.c (unescape_nonascii): append excape sequence as-is not
 | 
			
		||||
	  unescaped character, to get rid of unexpected meta-character.
 | 
			
		||||
	  [ruby-core:67193] [Bug #10670]
 | 
			
		||||
 | 
			
		||||
Mon Dec 29 14:27:33 2014  Nobuyoshi Nakada  <nobu@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* doc/syntax/literals.rdoc (Symbols): now Symbols created by
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										3
									
								
								re.c
									
										
									
									
									
								
							
							
						
						
									
										3
									
								
								re.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -2298,9 +2298,10 @@ unescape_nonascii(const char *p, const char *end, rb_encoding *enc,
 | 
			
		|||
              case 'M': /* \M-X, \M-\C-X, \M-\cX */
 | 
			
		||||
                p = p-2;
 | 
			
		||||
		if (enc == rb_usascii_encoding()) {
 | 
			
		||||
		    const char *pbeg = p;
 | 
			
		||||
		    c = read_escaped_byte(&p, end, err);
 | 
			
		||||
		    if (c == (char)-1) return -1;
 | 
			
		||||
		    rb_str_buf_cat(buf, &c, 1);
 | 
			
		||||
		    rb_str_buf_cat(buf, pbeg, p-pbeg);
 | 
			
		||||
		}
 | 
			
		||||
		else {
 | 
			
		||||
		    if (unescape_escaped_nonascii(&p, end, enc, buf, encp, err) != 0)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1579,4 +1579,13 @@ class TestM17N < Test::Unit::TestCase
 | 
			
		|||
    assert_same(str, str.scrub!)
 | 
			
		||||
    assert_equal("\uFFFD\uFFFD\uFFFD", str)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_escaped_metachar
 | 
			
		||||
    bug10670 = '[ruby-core:67193] [Bug #10670]'
 | 
			
		||||
 | 
			
		||||
    escape_plain = /\A[\x5B]*\z/.freeze
 | 
			
		||||
 | 
			
		||||
    assert_match(escape_plain, 0x5b.chr(::Encoding::UTF_8), bug10670)
 | 
			
		||||
    assert_match(escape_plain, 0x5b.chr, bug10670)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue