Skip to content

Commit a3d911d

Browse files
Don't consume char at AMBIGUOUS_AMPERSAND start
1 parent 2447729 commit a3d911d

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/nu/validator/htmlparser/impl/Tokenizer.java

+12-10
Original file line numberDiff line numberDiff line change
@@ -3533,14 +3533,14 @@ private void ensureBufferSpace(int inputLength) throws SAXException {
35333533
}
35343534
// XXX reorder point
35353535
case AMBIGUOUS_AMPERSAND:
3536+
/*
3537+
* Unlike the definition is the spec, we don't consume the
3538+
* next input character right away when entering this state;
3539+
* that's because our current implementation differs from
3540+
* the spec in that we've already consumed the relevant
3541+
* character *before* entering this state.
3542+
*/
35363543
ampersandloop: for (;;) {
3537-
if (reconsume) {
3538-
if (++pos == endPos) {
3539-
break stateloop;
3540-
}
3541-
pos--;
3542-
c = checkChar(buf, pos);
3543-
}
35443544
if (c == ';') {
35453545
errNoNamedCharacterMatch();
35463546
} else if ((c >= '0' && c <= '9')
@@ -3550,11 +3550,13 @@ private void ensureBufferSpace(int inputLength) throws SAXException {
35503550
if ((returnState & DATA_AND_RCDATA_MASK) == 0) {
35513551
cstart = pos;
35523552
}
3553-
/* The following pos++ is necessary due to how we’ve
3554-
* handled the "reconsume" block for this case. */
3555-
pos++;
3553+
if (++pos == endPos) {
3554+
break stateloop;
3555+
}
3556+
c = checkChar(buf, pos);
35563557
continue;
35573558
}
3559+
reconsume = true;
35583560
state = transition(state, returnState, reconsume, pos);
35593561
continue stateloop;
35603562
}

0 commit comments

Comments
 (0)