+2005-04-15 David Hyatt <hyatt@apple.com>
+
+ Fix for row 13 of the Acid2 test. Change HTML comment parsing in strict mode to do proper SGML parsing,
+ checking for pairs of -- and only being willing to close the comment if every -- is paired up.
+
+ * khtml/html/htmltokenizer.cpp:
+ (khtml::HTMLTokenizer::parseComment):
+
2005-04-12 Maciej Stachowiak <mjs@apple.com>
Reviewed by Richard.
void HTMLTokenizer::parseComment(TokenizerString &src)
{
+ bool strict = !parser->doc()->inCompatMode();
+ int delimiterCount = 0;
+ bool canClose = false;
checkScriptBuffer(src.length());
while ( !src.isEmpty() ) {
scriptCode[ scriptCodeSize++ ] = *src;
qDebug("comment is now: *%s*",
QConstString((QChar*)src.current(), QMIN(16, src.length())).string().latin1());
#endif
- if (src->unicode() == '>') {
+
+ if (strict) {
+ if (src->unicode() == '-') {
+ delimiterCount++;
+ if (delimiterCount == 2) {
+ delimiterCount = 0;
+ canClose = !canClose;
+ }
+ }
+ else
+ delimiterCount = 0;
+ }
+
+ if ((!strict || canClose) && src->unicode() == '>') {
bool handleBrokenComments = brokenComments && !(script || style);
int endCharsCount = 1; // start off with one for the '>' character
- if (scriptCodeSize > 2 && scriptCode[scriptCodeSize-3] == '-' && scriptCode[scriptCodeSize-2] == '-') {
- endCharsCount = 3;
- }
- else if (scriptCodeSize > 3 && scriptCode[scriptCodeSize-4] == '-' && scriptCode[scriptCodeSize-3] == '-' &&
- scriptCode[scriptCodeSize-2] == '!') {
- // Other browsers will accept --!> as a close comment, even though it's
- // not technically valid.
- endCharsCount = 4;
+ if (!strict) {
+ // In quirks mode just check for -->
+ if (scriptCodeSize > 2 && scriptCode[scriptCodeSize-3] == '-' && scriptCode[scriptCodeSize-2] == '-') {
+ endCharsCount = 3;
+ }
+ else if (scriptCodeSize > 3 && scriptCode[scriptCodeSize-4] == '-' && scriptCode[scriptCodeSize-3] == '-' &&
+ scriptCode[scriptCodeSize-2] == '!') {
+ // Other browsers will accept --!> as a close comment, even though it's
+ // not technically valid.
+ endCharsCount = 4;
+ }
}
- if (handleBrokenComments || endCharsCount > 1) {
+ if (canClose || handleBrokenComments || endCharsCount > 1) {
++src;
if (!( script || xmp || textarea || style)) {
if (includesCommentsInDOM) {