Don't get confused by multiple right square brackets when parsing CDATA sections. bug 325532, r+sr=jst

This commit is contained in:
mrbkap%gmail.com 2006-02-06 18:54:53 +00:00
parent c7bb9a4956
commit f1f0eb9711

View File

@ -1036,7 +1036,17 @@ CCDATASectionToken::Consume(PRUnichar aChar, nsScanner& aScanner,
PRBool inCDATA = (aFlag & NS_IPARSER_FLAG_VIEW_SOURCE) &&
StringBeginsWith(mTextValue, NS_LITERAL_STRING("[CDATA["));
if (inCDATA) {
result = aScanner.Peek(aChar);
// Consume all right square brackets to catch cases such as:
// <![CDATA[foo]]]>
while (true) {
result = aScanner.Peek(aChar);
if (result != NS_OK || aChar != kRightSquareBracket) {
break;
}
mTextValue.Append(aChar);
aScanner.GetChar(aChar);
}
} else {
nsAutoString dummy; // Skip any bad data
result = aScanner.ReadUntil(dummy, kGreaterThan, PR_FALSE);