Fix for bug 62782. Edge case in scanner caused us to drop characters occasionally. Thanks to jst for identification of the problem. r=harishd, sr=jst

This commit is contained in:
vidur%netscape.com 2000-12-18 20:58:53 +00:00
parent 295e3e781a
commit 2c971746c9
2 changed files with 16 additions and 10 deletions

View File

@ -717,12 +717,15 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScan
//if((eHTMLTag_style==theTag) || (eHTMLTag_script==theTag)) {
if(gHTMLElements[theTag].CanContainType(kCDATA)) {
nsAutoString endTag; endTag.AssignWithConversion(nsHTMLTags::GetStringValue(theTag));
endTag.InsertWithConversion("</",0,2);
nsAutoString endText, endTagName;
endTagName.AssignWithConversion(nsHTMLTags::GetStringValue(theTag));
endText.Assign(endTagName);
endText.InsertWithConversion("</",0,2);
CToken* textToken=theAllocator->CreateTokenOfType(eToken_text,eHTMLTag_text);
result=((CTextToken*)textToken)->ConsumeUntil(0,PRBool(theTag!=eHTMLTag_script),aScanner,endTag,mParseMode,aFlushTokens); //tell new token to finish consuming text...
//endTag.Append(">");
CToken* endToken=theAllocator->CreateTokenOfType(eToken_end,theTag,endTag);
result=((CTextToken*)textToken)->ConsumeUntil(0,PRBool(theTag!=eHTMLTag_script),aScanner,endText,mParseMode,aFlushTokens); //tell new token to finish consuming text...
CToken* endToken=theAllocator->CreateTokenOfType(eToken_end,theTag,endTagName);
AddToken(textToken,result,&mTokenDeque,theAllocator);
AddToken(endToken,result,&mTokenDeque,theAllocator);
}

View File

@ -717,12 +717,15 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScan
//if((eHTMLTag_style==theTag) || (eHTMLTag_script==theTag)) {
if(gHTMLElements[theTag].CanContainType(kCDATA)) {
nsAutoString endTag; endTag.AssignWithConversion(nsHTMLTags::GetStringValue(theTag));
endTag.InsertWithConversion("</",0,2);
nsAutoString endText, endTagName;
endTagName.AssignWithConversion(nsHTMLTags::GetStringValue(theTag));
endText.Assign(endTagName);
endText.InsertWithConversion("</",0,2);
CToken* textToken=theAllocator->CreateTokenOfType(eToken_text,eHTMLTag_text);
result=((CTextToken*)textToken)->ConsumeUntil(0,PRBool(theTag!=eHTMLTag_script),aScanner,endTag,mParseMode,aFlushTokens); //tell new token to finish consuming text...
//endTag.Append(">");
CToken* endToken=theAllocator->CreateTokenOfType(eToken_end,theTag,endTag);
result=((CTextToken*)textToken)->ConsumeUntil(0,PRBool(theTag!=eHTMLTag_script),aScanner,endText,mParseMode,aFlushTokens); //tell new token to finish consuming text...
CToken* endToken=theAllocator->CreateTokenOfType(eToken_end,theTag,endTagName);
AddToken(textToken,result,&mTokenDeque,theAllocator);
AddToken(endToken,result,&mTokenDeque,theAllocator);
}