Permalink
Browse files

Fix #5521 - Escape globing characters in Rails::Paths::Path#expanded

  • Loading branch information...
1 parent 14b2cf6 commit 606737b42491b569092e3d267cee00ea683ad6a0 @byroot committed Mar 21, 2012
Showing with 9 additions and 1 deletion.
  1. +9 −1 railties/lib/rails/paths.rb
@@ -157,7 +157,7 @@ def expanded
path = File.expand_path(p, @root.path)
if @glob
- result.concat Dir[File.join(path, @glob)].sort
+ result.concat Dir[File.join(glob_escape(path), @glob)].sort
else
result << path
end
@@ -177,6 +177,14 @@ def existent_directories
end
alias to_a expanded
+
+ private
+
+ GLOB_ESCAPE = Regexp.new("[#{Regexp.escape('[]?{}*')}]")
+
+ def glob_escape(path)
+ path.gsub(GLOB_ESCAPE) { |c| "\\#{c}" }
+ end
end
end
end

0 comments on commit 606737b

Please sign in to comment.