mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
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:
+10
-1
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user