Merge pull request #2702 from takahashim/fix-string-match

fix infinite loop in String#match(arg) when arg is String
This commit is contained in:
Yukihiro "Matz" Matsumoto
2015-01-14 09:33:41 +09:00
+10 -1
View File
@@ -146,7 +146,16 @@ class String
##
# ISO 15.2.10.5.27
def match(re, &block)
re.match(self, &block)
if re.respond_to? :to_str
if Object.const_defined?(:Regexp)
r = Regexp.new(re)
r.match(self, &block)
else
raise NotImplementedError, "String#match needs Regexp class"
end
else
re.match(self, &block)
end
end
end