From bcceeba09b38eb8217f85aa5c11afac9eb9b888e Mon Sep 17 00:00:00 2001 From: takahashim Date: Wed, 14 Jan 2015 02:18:56 +0900 Subject: fix infinite loop in String#match(arg) when arg is String --- mrblib/string.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mrblib/string.rb b/mrblib/string.rb index 322cd0788..66a668e11 100644 --- a/mrblib/string.rb +++ b/mrblib/string.rb @@ -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 -- cgit v1.2.3