Bug 132785, regression in strict comment parsing. Although spec does not allow non-whitespace characters between last dash and greater than, there seem to be lots of pages out there that do this. Relax the code that detects comment end so this starts working again. r=harishd, sr=jst, a=asa.

This commit is contained in:
heikki@netscape.com
2002-03-23 01:18:52 +00:00
parent 931676c66e
commit 4f524a9601
2 changed files with 18 additions and 12 deletions

View File

@@ -1006,21 +1006,24 @@ CCommentToken::CCommentToken(const nsAReadableString& aName) : CHTMLToken(eHTMLT
mTextValue.Assign(aName);
}
// We must test if we have whitespace and >
static PRBool IsGoodCommentEnd(
static PRBool IsCommentEnd(
const nsReadingIterator<PRUnichar>& aCurrent,
const nsReadingIterator<PRUnichar>& aEnd,
nsReadingIterator<PRUnichar>& aGt)
{
nsReadingIterator<PRUnichar> current = aCurrent;
PRInt32 dashes = 0;
while (current != aEnd) {
while ((current != aEnd) && (dashes != 2)) {
if (*current == kGreaterThan) {
aGt = current;
return PR_TRUE;
}
if (!nsString::IsSpace(*current))
break;
if (*current == PRUnichar('-')) {
dashes++;
} else {
dashes = 0;
}
++current;
}
@@ -1053,7 +1056,7 @@ nsresult ConsumeStrictComment(nsScanner& aScanner, nsString& aString) {
}
balancedComment = !balancedComment; // We need to match '--' with '--'
if (balancedComment && IsGoodCommentEnd(current, end, gt)) {
if (balancedComment && IsCommentEnd(current, end, gt)) {
// done
current.advance(-2);
if (beginData != current) { // protects from <!---->