Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix #174

[JRUBY-6668] StringScanner#scan_until spins forever on UTF-8 data

We were not preparing the regex properly. Added that, and the
given example completes normally.
  • Loading branch information...
commit c550df63c678d05547b8fed04aeb3f955c66efc9 1 parent e4c8886
@headius headius authored
View
2  src/org/jruby/RubyRegexp.java
@@ -396,7 +396,7 @@ private Encoding checkEncoding(RubyString str, boolean warn) {
return enc;
}
- final Regex preparePattern(RubyString str) {
+ public final Regex preparePattern(RubyString str) {
check();
Encoding enc = checkEncoding(str, true);
if (enc == pattern.getEncoding()) return pattern;
View
5 src/org/jruby/ext/strscan/RubyStringScanner.java
@@ -227,10 +227,11 @@ private IRubyObject extractBegLen(Ruby runtime, int beg, int len) {
}
private IRubyObject scan(IRubyObject regex, boolean succptr, boolean getstr, boolean headonly) {
- if (!(regex instanceof RubyRegexp)) throw getRuntime().newTypeError("wrong argument type " + regex.getMetaClass() + " (expected Regexp)");
+ Ruby runtime = getRuntime();
+ if (!(regex instanceof RubyRegexp)) throw runtime.newTypeError("wrong argument type " + regex.getMetaClass() + " (expected Regexp)");
check();
- Regex pattern = ((RubyRegexp)regex).getPattern();
+ Regex pattern = ((RubyRegexp)regex).preparePattern(str);
clearMatched();
int rest = str.getByteList().getRealSize() - pos;
Please sign in to comment.
Something went wrong with that request. Please try again.