bug 70282: view-source loses the last tag in a document if the tag is unclosed. r=rbs sr=roc

git-svn-id: svn://10.0.0.236/trunk@165245 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mrbkap%gmail.com
2004-11-11 03:41:52 +00:00
parent 94a14c5359
commit 2d1d00b7e3
3 changed files with 65 additions and 18 deletions

View File

@@ -697,6 +697,10 @@ nsresult nsHTMLTokenizer::ConsumeAttributes(PRUnichar aChar,
if (NS_FAILED(result)) {
aToken->SetInError(PR_TRUE);
if (!aScanner.IsIncremental()) {
result = NS_OK;
}
}
aToken->SetAttributeCount(theAttrCount);
@@ -854,6 +858,7 @@ nsresult nsHTMLTokenizer::ConsumeEndTag(PRUnichar aChar,CToken*& aToken,nsScanne
nsTokenAllocator* theAllocator=this->GetTokenAllocator();
aToken=theAllocator->CreateTokenOfType(eToken_end,eHTMLTag_unknown);
PRInt32 theDequeSize=mTokenDeque.GetSize(); //remember this for later in case you have to unwind...
nsresult result=NS_OK;
if(aToken) {
@@ -869,7 +874,6 @@ nsresult nsHTMLTokenizer::ConsumeEndTag(PRUnichar aChar,CToken*& aToken,nsScanne
if(kGreaterThan != aChar) {
result = ConsumeAttributes(aChar, aToken, aScanner);
NS_ENSURE_SUCCESS(result, result);
}
else {
aScanner.GetChar(aChar);
@@ -883,6 +887,16 @@ nsresult nsHTMLTokenizer::ConsumeEndTag(PRUnichar aChar,CToken*& aToken,nsScanne
mFlags &= ~NS_IPARSER_FLAG_PRESERVE_CONTENT;
}
}
// Do the same thing as we do in ConsumeStartTag. Basically, if we've run
// out of room in this *section* of the document, pop all of the tokens
// we've consumed this round and wait for more data.
if(NS_FAILED(result)) {
while(mTokenDeque.GetSize()>theDequeSize) {
CToken* theToken=(CToken*)mTokenDeque.Pop();
IF_FREE(theToken, mTokenAllocator);
}
}
} //if
return result;
}