Last Comment Bug 2749 - Comments are incorrectly parsed: <!-- -- --> inside comment! <!-- -- -->
: Comments are incorrectly parsed: <!-- -- --> inside comment! <!-- -- -->
: regression, testcase
Product: Core
Classification: Components
Component: HTML: Parser (show other bugs)
: Trunk
: x86 Windows 98
: P2 normal (vote)
: mozilla0.9
Assigned To: harishd
: Hixie (not reading bugmail)
: Andrew Overholt [:overholt]
: 12025 (view as bug list)
Depends on: 1312 34662
Blocks: html4.01
  Show dependency treegraph
Reported: 1999-01-28 10:03 PST by Hixie (not reading bugmail)
Modified: 2009-12-14 09:25 PST (History)
5 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

Testcase for quirks mode coments (262 bytes, text/html)
1999-10-07 22:50 PDT, Masatoshi Kimura [:emk]
no flags Details
Testcase (192 bytes, text/html)
1999-10-24 14:47 PDT, Masatoshi Kimura [:emk]
no flags Details
Yet another testcase (509 bytes, text/html)
1999-10-29 20:48 PDT, Masatoshi Kimura [:emk]
no flags Details
Proposed patch (465 bytes, patch)
1999-10-29 21:22 PDT, Masatoshi Kimura [:emk]
no flags Details | Diff | Splinter Review

Description Hixie (not reading bugmail) 1999-01-28 10:03:27 PST
Comment delimiters are "--" while inside tags.

Thus: <!-- in --  -- in --  -- in -->
where "in" shows what is commented.

On the test page quoted, all is explained.
Comment 1 John Morrison 1999-01-28 14:48:59 PST
fixed the URL to what was intended
Comment 2 Hixie (not reading bugmail) 1999-01-29 05:08:59 PST
Eek! Thanks.
Comment 3 Hixie (not reading bugmail) 1999-01-30 05:28:59 PST
Incidentally, the test page doesn't (yet) test this:

 <A name=abc -- href="comment" --> </A>

That is, "--" delimiters also delimit comments inside element tags. Thus the
above should be parsed as:

 <A name=abc > </A>

...and the following:

 <A -- href=" -- name=fred -- /"--> </A>

...should be parsed as:

 <A  name=fred > </A>

...and the following:

 <DEL datetime="1999-01-30T1325Z" --> Never mind. --> </DEL>

...should be parsed as:

 <DEL datetime="1999-01-30T1325Z" > </DEL>

Eventually I'll add these to the test page quoted above.
Comment 4 David Baron :dbaron: ⌚️UTC-10 1999-02-02 14:02:59 PST
Are you sure about those examples above, Ian?  I think the -- only applies when
one is within SGML processing instructions, i.e, <! ... >, not any old tags.  I
don't have a copy of any SGML standard (I think it's on paper only!), so I'm
not sure.  But nsgmls (via agrees
with me.
Comment 5 Hixie (not reading bugmail) 1999-02-02 14:22:59 PST
If nsgmls says I'm wrong, then I'm wrong.

The SGML spec is indeed paper only, I was basing my assertion on what
I could remember of a tutorial I read a few months back. Please therefore
disregard anything I previously said about comments in any old tags.
Comment 6 Hixie (not reading bugmail) 1999-02-02 16:14:59 PST
See the end of the quoted test page:
Basically, "->" is terminating comments, instead of "--".

This is causing pages to break, for example:
...has its comment visible at the top!
Comment 7 leger 1999-02-03 08:04:59 PST
Setting all current Open Critical and Major to M3
Comment 8 rickg 1999-02-16 01:01:59 PST
Fixed by update to comment parsing. We should now be handling common practice of
comments correctly now, but still not to spec. That won't get enabled until we
actually have a strict dtd.
Comment 9 Hixie (not reading bugmail) 1999-02-23 12:14:59 PST
Will not verify until strict parsing mode enabled.
Comment 10 Hixie (not reading bugmail) 1999-03-26 20:09:59 PST
Query: Is "->" supposed to end comments in NavQuirks mode?
Comment 11 Jan Carpenter 1999-07-09 13:42:59 PDT
Reporter awaiting developer response.
Comment 12 rickg 1999-07-09 14:13:59 PDT
We run in quirks mode by default -- and so yes, -> can close a comment. In
non-quirks mode you will have to use correctly formed comments.
Comment 13 Jan Carpenter 1999-07-09 18:43:59 PDT
Comment 14 Hixie (not reading bugmail) 1999-07-16 18:37:59 PDT
janc: Strict mode parsing is not yet enabled. This bug cannot be verified until
it is. I am adding a dependency to indicate this and removing the verified
notation on this bug for now.

In any case, how exactly did you verify that the bug was fixed? Viewer still
fails two out of three of the tests on the test page for this bug. (It fails
them because it parses in quirk mode.)
Comment 15 Jan Carpenter 1999-07-30 18:43:59 PDT
This was verified per the developer.
Clearing "Resolved Fixed" and re-opening bug.
Comment 16 leger 1999-08-02 17:26:59 PDT
Clearing Fixed resolution due to reopen.
Comment 17 leger 1999-08-02 17:39:59 PDT
Moving from M3 to M9 milestone since reopen.  rickg, please set to later
milestone if more appropriate.
Comment 18 rickg 1999-08-06 01:54:59 PDT
I'll move this to REMIND, since we're working per Nav.
Comment 19 Hixie (not reading bugmail) 1999-09-26 16:26:59 PDT
Ok, DOCTYPE-linked standard mode is now hooked up. We still fail these tests,
even though the test page's DOCTYPE should trigger standard mode.

Comment 20 Masatoshi Kimura [:emk] 1999-10-04 20:30:59 PDT
*** Bug 12025 has been marked as a duplicate of this bug. ***
Comment 21 harishd 1999-10-06 15:49:59 PDT
Strict comment handling has been hooked up to the noquirks.
Comment 22 Masatoshi Kimura [:emk] 1999-10-07 22:42:59 PDT
Even if quirks mode, "->" should not terminate comments
because "->" do not end comments both on Nav4 and on IE.
Comment 23 Masatoshi Kimura [:emk] 1999-10-07 22:50:59 PDT
Created attachment 2027 [details]
Testcase for quirks mode coments
Comment 24 leger 1999-10-08 03:49:59 PDT
Clearing FIXED resolution due to reopen.
Comment 25 harishd 1999-10-14 16:45:59 PDT
Checked in a fix..
Comment 26 Masatoshi Kimura [:emk] 1999-10-22 07:13:59 PDT
Verified fixed.
Comment 27 Masatoshi Kimura [:emk] 1999-10-24 14:46:59 PDT
Oops. I found standards mode comment handling is still incorrect.
Comment 28 Masatoshi Kimura [:emk] 1999-10-24 14:47:59 PDT
Created attachment 2396 [details]
Comment 29 harishd 1999-10-28 20:06:59 PDT
Good catch.

Tweaked strict comment handling.  Marking FIXED.
Comment 30 Masatoshi Kimura [:emk] 1999-10-29 20:47:59 PDT
Still incorrect using 1999102908 build. Reopening.
Comment 31 Masatoshi Kimura [:emk] 1999-10-29 20:48:59 PDT
Created attachment 2503 [details]
Yet another testcase
Comment 32 Masatoshi Kimura [:emk] 1999-10-29 21:22:59 PDT
Created attachment 2504 [details] [diff] [review]
Proposed patch
Comment 33 harishd 1999-10-30 15:48:59 PDT
The fix is already in.. which build did you check?
Comment 34 harishd 1999-10-31 11:20:59 PST
Oops, I'm sorry...I see what you're saying.  When I tweaked the strict comment
I, some how, forgot to comment out the line that you'd bad :(

Will checkin the change Monday.  Thanx for catching it.
Comment 35 leger 1999-11-02 16:20:59 PST
Clearing FIXED resolution due to reopen of this bug.
Comment 36 Hixie (not reading bugmail) 1999-11-04 19:58:59 PST
Note. The eviltest has been updated to contain all permutations mentioned
herein. Thanks to for spotting them. :-)
Comment 37 harishd 1999-11-15 16:31:59 PST
Marking FIXED.
Comment 38 Hixie (not reading bugmail) 1999-11-17 10:38:59 PST
All tests on the evil test (a superset of the attachements) pass correctly.
Marking verified.
Comment 39 Hixie (not reading bugmail) 2001-03-10 18:53:42 PST
Reopening. fails again.
Comment 40 clayton 2001-03-16 10:20:26 PST
Ian, would you try to identify the time frame in which the regression was 
reintroduced?  If it appeared recently it might be much easier to find and fix. 
How critical is this?  It says 'major' severity, it that accurate?
Comment 41 Hixie (not reading bugmail) 2001-03-16 20:34:52 PST
I would bet that this regressed when we turned off the Strict HTML parser.
->normal; this isn't major any more.
Comment 42 harishd 2001-03-19 09:34:41 PST
Ian, you're right. It did regress when the strict DTD got turned off. It's still 
possible to turn on strict comment parsing but I'm not sure if it's worth doing 
so because we now display exactly the way Nav4.x and IE do. Ian, what is your 
take on this?
Comment 43 Hixie (not reading bugmail) 2001-03-20 11:56:07 PST
If it is easy to turn on in standards mode, then we should. How easy is it?

I would say it's worth fixing, but not necessarily for mozilla0.9. If it is not
an easy fix, then I propose targetting mozilla1.0.
Comment 44 harishd 2001-03-20 12:16:02 PST
Ian, refer to bug 53011. How do we handle cases like this ( as in bug 53011 ) if 
the strict comment parsing is turned on?  evangelize?

Btw, it's a onliner to turn on strict comment parsing.
Comment 45 Hixie (not reading bugmail) 2001-03-20 14:57:55 PST
Yes, we would evangelise. This is just like we do with all the other "bugs" that
pages that trigger standard mode uncover, such as the inline box model issues.

Thankfully, very few broken pages trigger standard mode.

If it's a one line fix, I would recommend we do it for 0.9.
Comment 46 rubydoo123 2001-03-20 16:04:19 PST
I agree with Ian, if you can get this one in that would be a good thing. I was 
working with another bug and found this to happen:

original reduced test:
<META NAME=GENERATOR CONTENT="Microsoft FrontPage 4.0">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

commented it out, but placed the close comment as a single dash:
<META NAME=GENERATOR CONTENT="Microsoft FrontPage 4.0">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

and when I dumped the html, this is what the content was:
<META NAME=GENERATOR CONTENT="Microsoft FrontPage 4.0">-->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

Note the closing comment is placed after the first meta element -- why is that? 
In addition, note that the -> is escaped and within the body

Not sure if the resolution of this bug will resolve that -- Ian, is this similar 
to issues that you encountered?

Should this be a new bug? If so, I will gladly open one up
Comment 47 Hixie (not reading bugmail) 2001-03-20 17:19:49 PST
beppe: I'm not sure that's a bug, but file it or mail me directly so that we can
take the discussion out of this bug. (per HTML/SGML/XML, "->" is not a comment
delimiter, so it shouldn't close the comment, IMHO; hence why I say this is 
correct. I dunno, I might be wrong.)
Comment 48 harishd 2001-03-31 15:08:36 PST
Enabled strict comment parsing. Marking FIXED.
Comment 49 Hixie (not reading bugmail) 2001-04-02 16:27:37 PDT
Comment 50 Alix Guillard 2009-12-14 08:04:50 PST
I still get it with version 3.5 for Mac see
Comment 51 David Baron :dbaron: ⌚️UTC-10 2009-12-14 09:25:49 PST
(In reply to comment #50)
> I still get it with version 3.5 for Mac see

You're actually complaining about the opposite, i.e., bug 214476.  (This bug fixed us to behave as SGML specifies, or something like that, but that breaks your page.  Bug 214476 is a request to undo that, which we will when we switch to our HTML5 parser.)

It's an interesting case, since it involves commenting out IDN in the xn-- form, though.

Note You need to log in before you can comment on or make changes to this bug.