Skip to content
Browse files

Fixed tokeniser optimisation when scanning for missing data element c…

…lose tags.

Fixes #67
  • Loading branch information...
1 parent 7938bae commit c755b04e931e4cd870bbb4a6ac6b376b2340208a @jhy jhy committed Jan 18, 2011
Showing with 6 additions and 3 deletions.
  1. +6 −3 src/main/java/org/jsoup/parser/TokenQueue.java
View
9 src/main/java/org/jsoup/parser/TokenQueue.java
@@ -201,13 +201,16 @@ public String consumeToIgnoreCase(String seq) {
int start = pos;
String first = seq.substring(0, 1);
boolean canScan = first.toLowerCase().equals(first.toUpperCase()); // if first is not cased, use index of
- while (!isEmpty() && !matches(seq)) {
+ while (!isEmpty()) {
+ if (matches(seq))
+ break;
+
if (canScan) {
int skip = queue.indexOf(first, pos) - pos;
- if (skip <= 0)
+ if (skip == 0) // this char is the skip char, but not match, so force advance of pos
pos++;
else if (skip < 0) // no chance of finding, grab to end
- pos = queue.length() - 1;
+ pos = queue.length();
else
pos += skip;
}

0 comments on commit c755b04

Please sign in to comment.
Something went wrong with that request. Please try again.