Fix handling of XML PIs in view-source. Bug 91240, patch by Blake Kaplan

<mrbkap@gmail.com>, r=rbs, sr=jst
This commit is contained in:
bzbarsky%mit.edu 2004-10-09 18:20:38 +00:00
Родитель d2a2b2a6fd
Коммит 4a78e50fc5
1 изменённых файлов: 24 добавлений и 1 удалений

Просмотреть файл

@ -2223,7 +2223,30 @@ CInstructionToken::CInstructionToken(const nsAString& aString) : CHTMLToken(eHTM
*/
nsresult CInstructionToken::Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aFlag){
mTextValue.AssignLiteral("<?");
nsresult result=aScanner.ReadUntil(mTextValue,kGreaterThan,PR_TRUE);
nsresult result=NS_OK;
PRBool done=PR_FALSE;
while (NS_OK==result && !done) {
//Note, this call does *not* consume the >.
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;
}