lib/chef/mixin/find_preferred_file.rb in chef-0.9.6 vs lib/chef/mixin/find_preferred_file.rb in chef-0.9.8.beta.1
- old
+ new
@@ -45,13 +45,13 @@
cookbook.send(cookbook_method).each do |rf|
full = File.expand_path(rf)
name = File.basename(full)
case file_type
when :remote_file
- rf =~ /^.+#{cookbook_id}[\\|\/]files[\\|\/](.+?)[\\|\/]#{name}/
+ rf =~ /^.+#{Regexp.escape(cookbook_id)}[\\|\/]files[\\|\/](.+?)[\\|\/]#{Regexp.escape(name)}/
when :template
- rf =~ /^.+#{cookbook_id}[\\|\/]templates[\\|\/](.+?)[\\|\/]#{name}/
+ rf =~ /^.+#{Regexp.escape(cookbook_id)}[\\|\/]templates[\\|\/](.+?)[\\|\/]#{Regexp.escape(name)}/
end
singlecopy = $1
files[full] = {
:name => name,
:singlecopy => singlecopy,
@@ -76,10 +76,10 @@
file_list_str = file_list.keys.join("\n")
Chef::Log.debug("Searching for preferred file in\n#{file_list_str}")
preferences.each do |pref|
Chef::Log.debug("Looking for #{pref}")
- matcher = /^(.+#{pref})$/
+ matcher = /^(.+#{Regexp.escape(pref)})$/
if match = matcher.match(file_list_str)
return match[1]
end
end