From 70371ad98cf9424ad8367aaa588ef503bb79365c Mon Sep 17 00:00:00 2001 From: "timeless%mozdev.org" Date: Thu, 17 Mar 2005 19:38:01 +0000 Subject: [PATCH] Bug 160095 NOEMBED tag causes leaks as the skipped content is not consumed. patch by mrbkap@gmail.com r=rbs sr=brendan --- parser/htmlparser/src/CNavDTD.cpp | 7 +++++++ parser/htmlparser/src/nsElementTable.cpp | 6 +++--- parser/htmlparser/src/nsHTMLTokenizer.cpp | 7 +++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/parser/htmlparser/src/CNavDTD.cpp b/parser/htmlparser/src/CNavDTD.cpp index 1743ea37097..71d345202df 100644 --- a/parser/htmlparser/src/CNavDTD.cpp +++ b/parser/htmlparser/src/CNavDTD.cpp @@ -3229,6 +3229,12 @@ CNavDTD::OpenContainer(const nsCParserNode *aNode, result = HandleScriptToken(aNode); break; + case eHTMLTag_noembed: + // is unconditionally alternate content. + done = PR_FALSE; + mFlags |= NS_DTD_FLAG_ALTERNATE_CONTENT; + break; + case eHTMLTag_noscript: // we want to make sure that OpenContainer gets called below since we're // not doing it here @@ -3315,6 +3321,7 @@ CNavDTD::CloseContainer(const eHTMLTags aTag, eHTMLTags aTarget,PRBool aClosedBy break; case eHTMLTag_iframe: + case eHTMLTag_noembed: case eHTMLTag_noscript: case eHTMLTag_noframes: // switch from alternate content state to regular state diff --git a/parser/htmlparser/src/nsElementTable.cpp b/parser/htmlparser/src/nsElementTable.cpp index 6a9f36d3982..5ad47f1f910 100644 --- a/parser/htmlparser/src/nsElementTable.cpp +++ b/parser/htmlparser/src/nsElementTable.cpp @@ -859,9 +859,9 @@ void InitializeElementTable(void) { /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0,0, - /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special props, prop-range*/ kDiscardTag, kDefaultPropRange, - /*special parents,kids,skip*/ 0,0,eHTMLTag_noembed); + /*parent,incl,exclgroups*/ kFlowEntity, kFlowEntity, kNone, + /*special props, prop-range*/ 0, kNoPropRange, + /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown); Initialize( /*tag*/ eHTMLTag_noframes, diff --git a/parser/htmlparser/src/nsHTMLTokenizer.cpp b/parser/htmlparser/src/nsHTMLTokenizer.cpp index f5404b0c492..32fb8752ab3 100644 --- a/parser/htmlparser/src/nsHTMLTokenizer.cpp +++ b/parser/htmlparser/src/nsHTMLTokenizer.cpp @@ -817,9 +817,12 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar, PRBool isPCDATA = eHTMLTag_textarea == theTag || eHTMLTag_title == theTag; + // XXX This is an evil hack, we should be able to handle these properly + // in the DTD. if ((eHTMLTag_iframe == theTag && (mFlags & NS_IPARSER_FLAG_FRAMES_ENABLED)) || (eHTMLTag_noframes == theTag && (mFlags & NS_IPARSER_FLAG_FRAMES_ENABLED)) || - (eHTMLTag_noscript == theTag && (mFlags & NS_IPARSER_FLAG_SCRIPT_ENABLED))) { + (eHTMLTag_noscript == theTag && (mFlags & NS_IPARSER_FLAG_SCRIPT_ENABLED)) || + (eHTMLTag_noembed == theTag)) { isCDATA = PR_TRUE; } @@ -844,7 +847,7 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar, mFlags, done); - // Only flush tokens for <script>, to give oursevles more of a + // Only flush tokens for <script>, to give ourselves more of a // chance of allowing inlines to contain blocks. aFlushTokens = done && theTag == eHTMLTag_script; }