From 3331d6774f355e261644d7042cdeee0f03db3bc8 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 23 Feb 2013 00:48:44 +0000 Subject: dir.c: encoding check * dir.c (file_s_fnmatch, fnmatch_brace): encoding-incompatible pattern and string do not match, instead of exception. [ruby-dev:47069] [Bug #7911] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_fnmatch.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/ruby/test_fnmatch.rb') diff --git a/test/ruby/test_fnmatch.rb b/test/ruby/test_fnmatch.rb index d186638a7b..0b3f604df5 100644 --- a/test/ruby/test_fnmatch.rb +++ b/test/ruby/test_fnmatch.rb @@ -109,4 +109,19 @@ class TestFnmatch < Test::Unit::TestCase assert_file.for(feature5422).not_fnmatch?( "{.g,t}*", ".gem") assert_file.for(feature5422).fnmatch?("{.g,t}*", ".gem", File::FNM_EXTGLOB) end + + def test_unmatched_encoding + bug7911 = '[ruby-dev:47069] [Bug #7911]' + path = "\u{3042}" + pattern_ascii = 'a'.encode('US-ASCII') + pattern_eucjp = path.encode('EUC-JP') + assert_nothing_raised(ArgumentError, bug7911) do + assert(!File.fnmatch(pattern_ascii, path)) + assert(!File.fnmatch(pattern_eucjp, path)) + assert(!File.fnmatch(pattern_ascii, path, File::FNM_CASEFOLD)) + assert(!File.fnmatch(pattern_eucjp, path, File::FNM_CASEFOLD)) + assert(File.fnmatch("{*,#{pattern_ascii}}", path, File::FNM_EXTGLOB)) + assert(File.fnmatch("{*,#{pattern_eucjp}}", path, File::FNM_EXTGLOB)) + end + end end -- cgit v1.2.3