diff options
author | Claire McQuin <claire@getchef.com> | 2014-09-19 11:07:29 -0700 |
---|---|---|
committer | Claire McQuin <claire@getchef.com> | 2014-09-22 11:22:29 -0700 |
commit | 655fc195e18f4bf3802718003ced9bc5ee25f163 (patch) | |
tree | 3317d5cc82a9c01768ff3f95c50217b51d869700 /lib | |
parent | ed907ef4d64027212ceb0c082895b303844ff43f (diff) | |
download | chef-655fc195e18f4bf3802718003ced9bc5ee25f163.tar.gz |
Add method to escape glob reserved characters.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/util/path_helper.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/chef/util/path_helper.rb b/lib/chef/util/path_helper.rb index e9fb4e7773..9aea2645d7 100644 --- a/lib/chef/util/path_helper.rb +++ b/lib/chef/util/path_helper.rb @@ -133,6 +133,14 @@ class Chef def self.paths_eql?(path1, path2) canonical_path(path1) == canonical_path(path2) end + + # Paths which may contain glob-reserved characters need + # to be escaped before globbing can be done. + # http://stackoverflow.com/questions/14127343 + def self.escape_glob(*parts) + path = join(parts) + path.gsub(/[\\\{\}\[\]\*\?]/) { |x| "\\"+x } + end end end end |