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

Merge pull request #881 from stuporglue/master

Escape method definition names before using in regexp
This commit is contained in:
Conrad Irwin 2013-03-11 11:38:39 -07:00
commit db15bddb1e

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