diff --git a/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp b/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp index 84d2edb865e..5562aec537f 100644 --- a/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp +++ b/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp @@ -745,12 +745,28 @@ nsresult CCDATASectionToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt3 if (NS_OK==result && (!inCDATA || kGreaterThan == aChar)) { result=aScanner.GetChar(aChar); //strip off the > + + // XXX take me out when view source isn't stupid anymore + if (aFlag & NS_IPARSER_FLAG_VIEW_SOURCE) { + mTextValue.Append(aChar); + } done=PR_TRUE; } } else done=PR_TRUE; } } + + if (kEOF == result && !aScanner.IsIncremental()) { + // We ran out of space looking for the end of this CDATA section. + // In order to not completely lose the entire section, treat everything + // until the end of the document as part of the CDATA section and let + // the DTD handle it. + // XXX when view source actually displays errors, we'll need to propagate + // the EOF down to it (i.e., not do this if we're viewing source). + result = NS_OK; + } + return result; } diff --git a/mozilla/parser/htmlparser/src/nsViewSourceHTML.cpp b/mozilla/parser/htmlparser/src/nsViewSourceHTML.cpp index 2b0513cfea8..e565530fba9 100644 --- a/mozilla/parser/htmlparser/src/nsViewSourceHTML.cpp +++ b/mozilla/parser/htmlparser/src/nsViewSourceHTML.cpp @@ -1123,7 +1123,9 @@ NS_IMETHODIMP CViewSourceHTML::HandleToken(CToken* aToken,nsIParser* aParser) { nsAutoString theStr; theStr.AssignLiteral("GetStringValue()); - theStr.AppendLiteral(">"); + // Treat CDATA sections specially because they remember their last + // character and can come back malformed. +// theStr.AppendLiteral(">"); result=WriteTag(mCDATATag,theStr,0,PR_TRUE); } break;