From 427f731b675f6e51bf2a9c74680090738daa2f84 Mon Sep 17 00:00:00 2001 From: "mrbkap%gmail.com" Date: Wed, 15 Jun 2005 18:20:29 +0000 Subject: [PATCH] bug 142965: Handling misplaced content with a stray end tag around causes the tag that caused us to handle the misplaced content to lose its attributes. r=jst sr+a=brendan git-svn-id: svn://10.0.0.236/trunk@174633 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/parser/htmlparser/src/CNavDTD.cpp | 25 +++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/mozilla/parser/htmlparser/src/CNavDTD.cpp b/mozilla/parser/htmlparser/src/CNavDTD.cpp index a7e7a8c31fb..be1d7fef62f 100644 --- a/mozilla/parser/htmlparser/src/CNavDTD.cpp +++ b/mozilla/parser/htmlparser/src/CNavDTD.cpp @@ -1944,10 +1944,27 @@ nsresult CNavDTD::HandleEndToken(CToken* aToken) { // Ex. Hello

There PRBool theParentContains=-1; //set to -1 to force canomit to recompute. if(!CanOmit(theParentTag,theChildTag,theParentContains)) { - IF_HOLD(aToken); - mTokenizer->PushTokenFront(aToken); //put this end token back... - CHTMLToken* theToken = NS_STATIC_CAST(CHTMLToken*,mTokenAllocator->CreateTokenOfType(eToken_start,theChildTag)); - mTokenizer->PushTokenFront(theToken); //put this new token onto stack... + CHTMLToken* theStartToken = NS_STATIC_CAST(CHTMLToken*,mTokenAllocator->CreateTokenOfType(eToken_start,theChildTag)); + + // This check for NS_DTD_FLAG_IN_MISPLACED_CONTENT was added + // to fix bug 142965. + if (!(mFlags & NS_DTD_FLAG_IN_MISPLACED_CONTENT)) { + // We're not handling misplaced content right now, just push + // these new tokens back on the stack and handle them in the + // regular flow of HandleToken. + IF_HOLD(aToken); + mTokenizer->PushTokenFront(aToken); //put this end token back... + mTokenizer->PushTokenFront(theStartToken); //put the new token onto the stack... + } + else { + // Oops, we're in misplaced content. Handle these tokens + // directly instead of trying to push them onto the tokenizer + // stack. + result = HandleToken(theStartToken, mParser); + NS_ENSURE_SUCCESS(result, result); + + result = HandleToken(aToken, mParser); + } } } return result;