Bug 1749522 - When plain text encoding speculation fails, restart the plaintext mode of the tokenizer. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D135830
This commit is contained in:
Henri Sivonen
2022-01-17 09:16:10 +00:00
parent 5a689a4c73
commit c6ef982f5e
4 changed files with 14 additions and 0 deletions

View File

@@ -1869,6 +1869,13 @@ void nsHtml5StreamParser::DiscardMetaSpeculation() {
mTokenizer->setLineNumber(1);
mLastWasCR = false;
if (mMode == PLAIN_TEXT || mMode == VIEW_SOURCE_PLAIN) {
// resetToDataState() above logically rewinds to the state before
// the plain text start, so we need to start plain text again to
// put the tokenizer into the plain text state.
mTokenizer->StartPlainText();
}
mFirstBuffer = mLastBuffer;
mFirstBuffer->setStart(0);
mFirstBuffer->setEnd(0);