From 5d9b49edf052112af0624232be9b333d2c18a59b Mon Sep 17 00:00:00 2001 From: "vidur%netscape.com" Date: Thu, 22 Jul 1999 04:46:57 +0000 Subject: [PATCH] Deal with multiple BODY elements passed by the parser by ignoring all but the first --- .../html/document/src/nsHTMLFragmentContentSink.cpp | 12 +++++++++++- .../html/document/src/nsHTMLFragmentContentSink.cpp | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/content/html/document/src/nsHTMLFragmentContentSink.cpp b/content/html/document/src/nsHTMLFragmentContentSink.cpp index 52dcbddd393..acec068bac6 100644 --- a/content/html/document/src/nsHTMLFragmentContentSink.cpp +++ b/content/html/document/src/nsHTMLFragmentContentSink.cpp @@ -99,6 +99,7 @@ public: nsresult FlushText(); PRBool mHitSentinel; + PRBool mSeenBody; nsIContent* mRoot; nsIParser* mParser; @@ -132,6 +133,7 @@ nsHTMLFragmentContentSink::nsHTMLFragmentContentSink() { NS_INIT_REFCNT(); mHitSentinel = PR_FALSE; + mSeenBody = PR_TRUE; mRoot = nsnull; mParser = nsnull; mCurrentForm = nsnull; @@ -292,7 +294,15 @@ nsHTMLFragmentContentSink::CloseHead(const nsIParserNode& aNode) NS_IMETHODIMP nsHTMLFragmentContentSink::OpenBody(const nsIParserNode& aNode) { - return OpenContainer(aNode); + // Ignore repeated BODY elements. The DTD is just sending them + // to us for compatibility reasons that don't apply here. + if (!mSeenBody) { + mSeenBody = PR_TRUE; + return OpenContainer(aNode); + } + else { + return NS_OK; + } } NS_IMETHODIMP diff --git a/layout/html/document/src/nsHTMLFragmentContentSink.cpp b/layout/html/document/src/nsHTMLFragmentContentSink.cpp index 52dcbddd393..acec068bac6 100644 --- a/layout/html/document/src/nsHTMLFragmentContentSink.cpp +++ b/layout/html/document/src/nsHTMLFragmentContentSink.cpp @@ -99,6 +99,7 @@ public: nsresult FlushText(); PRBool mHitSentinel; + PRBool mSeenBody; nsIContent* mRoot; nsIParser* mParser; @@ -132,6 +133,7 @@ nsHTMLFragmentContentSink::nsHTMLFragmentContentSink() { NS_INIT_REFCNT(); mHitSentinel = PR_FALSE; + mSeenBody = PR_TRUE; mRoot = nsnull; mParser = nsnull; mCurrentForm = nsnull; @@ -292,7 +294,15 @@ nsHTMLFragmentContentSink::CloseHead(const nsIParserNode& aNode) NS_IMETHODIMP nsHTMLFragmentContentSink::OpenBody(const nsIParserNode& aNode) { - return OpenContainer(aNode); + // Ignore repeated BODY elements. The DTD is just sending them + // to us for compatibility reasons that don't apply here. + if (!mSeenBody) { + mSeenBody = PR_TRUE; + return OpenContainer(aNode); + } + else { + return NS_OK; + } } NS_IMETHODIMP