mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	file.c: skip invalid byte
* file.c (rb_str_normalize_ospath): skip invalid byte sequence not to loop infinitely. this case usually does not happen as the input name should come from real file systems. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									548497d545
								
							
						
					
					
						commit
						8a0ab36db1
					
				
					 3 changed files with 15 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,9 @@
 | 
			
		|||
Tue Jul  7 15:02:18 2015  Nobuyoshi Nakada  <nobu@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* file.c (rb_str_normalize_ospath): skip invalid byte sequence not
 | 
			
		||||
	  to loop infinitely.  this case usually does not happen as the
 | 
			
		||||
	  input name should come from real file systems.
 | 
			
		||||
 | 
			
		||||
Tue Jul  7 14:40:08 2015  Koichi Sasada  <ko1@atdot.net>
 | 
			
		||||
 | 
			
		||||
	* vm_backtrace.c: remove debug flag introduced accidentaly.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										2
									
								
								file.c
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								file.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -294,6 +294,8 @@ rb_str_normalize_ospath(const char *ptr, long len)
 | 
			
		|||
	    rb_str_append(str, rb_str_normalize_ospath0(p1, p-p1));
 | 
			
		||||
	    rb_str_cat2(str, "\xEF\xBF\xBD");
 | 
			
		||||
	    p += 1;
 | 
			
		||||
	    p1 = p;
 | 
			
		||||
	    continue;
 | 
			
		||||
	}
 | 
			
		||||
	l = MBCLEN_CHARFOUND_LEN(r);
 | 
			
		||||
	c = rb_enc_mbc_to_codepoint(p, e, enc);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -59,7 +59,6 @@ class Test_StringNormalize < Test::Unit::TestCase
 | 
			
		|||
      assert_equal expected, result,
 | 
			
		||||
        "#{expected.dump} is expected but #{src.dump}"
 | 
			
		||||
    end
 | 
			
		||||
  rescue NotImplementedError
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_not_normalize_kc
 | 
			
		||||
| 
						 | 
				
			
			@ -79,7 +78,6 @@ class Test_StringNormalize < Test::Unit::TestCase
 | 
			
		|||
      assert_equal src, result,
 | 
			
		||||
        "#{src.dump} is expected not to be normalized, but #{result.dump}"
 | 
			
		||||
    end
 | 
			
		||||
  rescue NotImplementedError
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_dont_normalize_hfsplus
 | 
			
		||||
| 
						 | 
				
			
			@ -101,6 +99,11 @@ class Test_StringNormalize < Test::Unit::TestCase
 | 
			
		|||
      assert_equal src, result,
 | 
			
		||||
        "#{src.dump} is expected not to be normalized, but #{result.dump}"
 | 
			
		||||
    end
 | 
			
		||||
  rescue NotImplementedError
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
  def test_invalid_sequence
 | 
			
		||||
    assert_separately(%w[-r-test-/string/string], <<-'end;')
 | 
			
		||||
      assert_equal("\u{fffd}", Bug::String.new("\xff").normalize_ospath)
 | 
			
		||||
    end;
 | 
			
		||||
  end
 | 
			
		||||
end if Bug::String.method_defined?(:normalize_ospath)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue