From 1cb22f67a01aee8c37719a134ca176538665a2a5 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Sat, 9 Oct 2004 18:20:38 +0000 Subject: [PATCH] Fix handling of XML PIs in view-source. Bug 91240, patch by Blake Kaplan , r=rbs, sr=jst git-svn-id: svn://10.0.0.236/trunk@163481 18797224-902f-48f8-a5cc-f745e15eee43 --- .../parser/htmlparser/src/nsHTMLTokens.cpp | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp b/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp index c3b0dda7c59..f288c15e34a 100644 --- a/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp +++ b/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp @@ -2223,7 +2223,30 @@ CInstructionToken::CInstructionToken(const nsAString& aString) : CHTMLToken(eHTM */ nsresult CInstructionToken::Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aFlag){ mTextValue.AssignLiteral(". + result=aScanner.ReadUntil(mTextValue,kGreaterThan,PR_FALSE); + if (NS_SUCCEEDED(result)) { + //In HTML, PIs end with a '>', in XML, they end with a '?>'. Cover both + //cases here. + if (!(aFlag & NS_IPARSER_FLAG_XML) || kQuestionMark==mTextValue.Last()) { + //This really is the end of the PI. + done=PR_TRUE; + } + //Need to append this character no matter what. + aScanner.GetChar(aChar); + mTextValue.Append(aChar); + } + } + + if (kEOF==result && !aScanner.IsIncremental()) { + //Hide the EOF result because there is no more text coming. + result=NS_OK; + } + return result; }