Closed
Description
If the string contain umlaut characters, then JRuby hangs while trying to match the regular expression pattern. The below code snippet always hang with JRuby 1.7.20
public class RubyRegexTest
{
public static void main(String[] args)
{
// System.out.println("ütest");
Ruby runtime = Ruby.newInstance();
String regPattern = "(?-mix:^(.*\\*\\/)?\\s*(\\}|\\))([^{]*\\{)?([;,]?\\s*|\\.[^{]*|\\s*\\)[;\\s]*)$)";
RubyRegexp regexp = RubyRegexp.newRegexp(runtime, regPattern, new RegexpOptions(KCode.UTF8, true));
System.out.println(matchesRegexp(regexp, "console.log('testü');"));
System.out.println("Done!");
}
protected static boolean matchesRegexp(RubyRegexp regexp, String lineContent)
{
if (regexp == null)
{
return false;
}
Ruby runtime = regexp.getRuntime();
RubyString string = runtime.newString(lineContent);
IRubyObject matcher = regexp.match_m(regexp.getRuntime().getCurrentContext(), string);
return !matcher.isNil();
}
}