Commit 16884b87 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

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

fix infinite loop in String#match(arg) when arg is String
parents d405eb55 bcceeba0
...@@ -146,7 +146,16 @@ class String ...@@ -146,7 +146,16 @@ class String
## ##
# ISO 15.2.10.5.27 # ISO 15.2.10.5.27
def match(re, &block) 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
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment