Permalink
Browse files

Regexp.escape resource names in regexp matches as they may contain ch…

…aracters that also translate to regexp
  • Loading branch information...
1 parent 55c14a2 commit 56e33255320ff97795929a7efd360452a6a8f091 @joejulian joejulian committed Aug 24, 2012
@@ -27,15 +27,15 @@ def destroy
def exists?
out = rabbitmqctl('list_users').split(/\n/)[1..-2].detect do |line|
- line.match(/^#{resource[:name]}(\s+\S+|)$/)
+ line.match(/^#{Regexp.escape(resource[:name])}(\s+\S+|)$/)
end
end
# def password
# def password=()
def admin
match = rabbitmqctl('list_users').split(/\n/)[1..-2].collect do |line|
- line.match(/^#{resource[:name]}\s+\[(administrator)?\]/)
+ line.match(/^#{Regexp.escape(resource[:name])}\s+\[(administrator)?\]/)
end.compact.first
if match
(:true if match[1].to_s == 'administrator') || :false
@@ -23,7 +23,7 @@ def destroy
def exists?
out = rabbitmqctl('list_vhosts').split(/\n/)[1..-2].detect do |line|
- line.match(/^#{resource[:name]}$/)
+ line.match(/^#{Regexp.escape(resource[:name])}$/)
end
end

0 comments on commit 56e3325

Please sign in to comment.