summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2015-05-08 14:35:18 -0700
committerJay Mundrawala <jdmundrawala@gmail.com>2015-05-08 14:35:18 -0700
commit5b60038b0ca2636aeb425d51582dacc4905363ae (patch)
treef99a570a72759dc78913706137b74a1cb9b888cd /lib
parente4bf480137d5e06aba7c9fee4ae1577361a44a47 (diff)
downloadchef-5b60038b0ca2636aeb425d51582dacc4905363ae.tar.gz
Escape string inside regex
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/formatters/error_inspectors/resource_failure_inspector.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb b/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb
index 48572d909b..eeff5f10d2 100644
--- a/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb
@@ -63,7 +63,7 @@ class Chef
def recipe_snippet
return nil if dynamic_resource?
@snippet ||= begin
- if file = resource.source_line[/^(([\w]:)?[^:]+):([\d]+)/,1] and line = resource.source_line[/^#{file}:([\d]+)/,1].to_i
+ if file = resource.source_line[/^(([\w]:)?[^:]+):([\d]+)/,1] and line = resource.source_line[/^#{Regexp.escape(file)}:([\d]+)/,1].to_i
return nil unless ::File.exists?(file)
lines = IO.readlines(file)