mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
dir.c: glob brace expansion [Fix GH-1061]
* dir.c (ruby_brace_expand): glob brace expansion edge case fix. When there are closing braces '}' before a open brace '{' it must be ignored and considered as literal. [ruby-core:71138] [Bug #11609] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
66e41cbe4f
commit
ff3288fe5a
3 changed files with 13 additions and 1 deletions
|
@ -1,3 +1,10 @@
|
|||
Thu Oct 22 13:16:19 2015 Guilherme Reis Campos <guilhermekbsa@gmail.com>
|
||||
|
||||
* dir.c (ruby_brace_expand): glob brace expansion edge case fix.
|
||||
When there are closing braces '}' before a open brace '{' it
|
||||
must be ignored and considered as literal.
|
||||
[ruby-core:71138] [Bug #11609]
|
||||
|
||||
Thu Oct 22 13:13:49 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* io.c (argf_next_argv): check ARGV element type, and try
|
||||
|
|
2
dir.c
2
dir.c
|
@ -2041,7 +2041,7 @@ ruby_brace_expand(const char *str, int flags, ruby_glob_func *func, VALUE arg,
|
|||
if (*p == '{' && nest++ == 0) {
|
||||
lbrace = p;
|
||||
}
|
||||
if (*p == '}' && --nest <= 0) {
|
||||
if (*p == '}' && lbrace && --nest == 0) {
|
||||
rbrace = p;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -150,6 +150,11 @@ class TestDir < Test::Unit::TestCase
|
|||
|
||||
assert_equal([File.join(@root, "a")], Dir.glob(File.join(@root, 'a\\')))
|
||||
assert_equal(("a".."f").map {|f| File.join(@root, f) }.sort, Dir.glob(File.join(@root, '[abc/def]')).sort)
|
||||
|
||||
open(File.join(@root, "}}{}"), "wb") {}
|
||||
open(File.join(@root, "}}a"), "wb") {}
|
||||
assert_equal(%w(}}{} }}a).map {|f| File.join(@root, f)}, Dir.glob(File.join(@root, '}}{\{\},a}')))
|
||||
assert_equal(%w(}}{} }}a b c).map {|f| File.join(@root, f)}, Dir.glob(File.join(@root, '{\}\}{\{\},a},b,c}')))
|
||||
end
|
||||
|
||||
def test_glob_recursive
|
||||
|
|
Loading…
Add table
Reference in a new issue