summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-20 08:59:19 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-20 08:59:19 +0000
commit310ab79f5392f102ab0ef0434c8e25f203f9a287 (patch)
tree8315d351ba7e821529d9bcd17f9dec2ea67b65d9
parent81c378400434dd15989a4b22d812cf2f78e6104f (diff)
merge revision(s) 49532:
dir.c: fix escaping multibyte char * dir.c (has_magic): fix escaping multibyte char, with glob meta-char in trailing bytes, e.g., Shift-JIS git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@49667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--dir.c6
-rw-r--r--test/ruby/test_dir_m17n.rb10
-rw-r--r--version.h2
3 files changed, 14 insertions, 4 deletions
diff --git a/dir.c b/dir.c
index 32f37beffc..0903ec8a14 100644
--- a/dir.c
+++ b/dir.c
@@ -1208,9 +1208,9 @@ has_magic(const char *p, const char *pend, int flags, rb_encoding *enc)
return MAGICAL;
case '\\':
- if (escape && !(c = *p++))
- return PLAIN;
- continue;
+ if (escape && p++ >= pend)
+ continue;
+ break;
#ifdef _WIN32
case '.':
diff --git a/test/ruby/test_dir_m17n.rb b/test/ruby/test_dir_m17n.rb
index 325b1571c9..143bf52afb 100644
--- a/test/ruby/test_dir_m17n.rb
+++ b/test/ruby/test_dir_m17n.rb
@@ -347,6 +347,16 @@ class TestDir_M17N < Test::Unit::TestCase
end
end
+ def test_glob_escape_multibyte
+ name = "\x81\\".force_encoding(Encoding::Shift_JIS)
+ with_tmpdir do
+ open(name, "w") {} rescue next
+ match, = Dir.glob("#{name}*")
+ next unless match and match.encoding == Encoding::Shift_JIS
+ assert_equal([name], Dir.glob("\\#{name}*"))
+ end
+ end
+
def test_entries_compose
bug7267 = '[ruby-core:48745] [Bug #7267]'
diff --git a/version.h b/version.h
index 65acfefa87..a4bbbb00bc 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.2.0"
#define RUBY_RELEASE_DATE "2015-02-20"
-#define RUBY_PATCHLEVEL 68
+#define RUBY_PATCHLEVEL 69
#define RUBY_RELEASE_YEAR 2015
#define RUBY_RELEASE_MONTH 2