diff --git a/src/nu/validator/htmlparser/impl/Tokenizer.java b/src/nu/validator/htmlparser/impl/Tokenizer.java index a673a1a1..4428027b 100755 --- a/src/nu/validator/htmlparser/impl/Tokenizer.java +++ b/src/nu/validator/htmlparser/impl/Tokenizer.java @@ -3529,9 +3529,13 @@ private void ensureBufferSpace(int inputLength) throws SAXException { if (candidate == -1) { // reconsume deals with CR, LF or nul - if (c == ';') { - errNoNamedCharacterMatch(); - } + // We can go ahead and emit an error here without + // needing to do an "if (c == ';')" check, because if + // we've gotten here, we've already examined enough of + // string after the ampersand to determine that the + // substring we've looked at so far doesn't match the + // beginning of any known named character references. + errNoNamedCharacterMatch(); emitOrAppendCharRefBuf(returnState); if ((returnState & DATA_AND_RCDATA_MASK) == 0) { cstart = pos;