1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Escape method names before using them in a regex

This commit is contained in:
Michael Moore 2013-03-11 13:25:58 -05:00
parent 7c8f9be176
commit 9dbfb4f969

View file

@ -179,11 +179,11 @@ class Pry
end
def singleton_method_definition?(name, definition_line)
/^define_singleton_method\(?\s*[:\"\']#{name}|^def\s*self\.#{name}/ =~ definition_line.strip
/^define_singleton_method\(?\s*[:\"\']#{Regexp.escape(name)}|^def\s*self\.#{Regexp.escape(name)}/ =~ definition_line.strip
end
def instance_method_definition?(name, definition_line)
/^define_method\(?\s*[:\"\']#{name}|^def\s*#{name}/ =~ definition_line.strip
/^define_method\(?\s*[:\"\']#{Regexp.escape(name)}|^def\s*#{Regexp.escape(name)}/ =~ definition_line.strip
end
private