Skip to content

Commit

Permalink
Fix #174
Browse files Browse the repository at this point in the history
[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
headius committed May 17, 2012
1 parent e4c8886 commit c550df6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/org/jruby/RubyRegexp.java
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/org/jruby/ext/strscan/RubyStringScanner.java
Expand Up @@ -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;
Expand Down

0 comments on commit c550df6

Please sign in to comment.