Tags:
create new tag
view all tags

Bug

Oops, stop the presses -- it turns out this is not a bug but is in accordance with the actual definition of HTML comment markers. Mozilla gets it right, IE gets it wrong. See "Resolution", below.

I have found a bug in Mozilla 1.1 (delivered with Mandrake 9.0). The bug should be reported if not already logged at Mozilla. I'd like to recruit help with the following steps:

  1. Determine whether the bug still exists in more recent versions of Mozilla (view MozillaBugWrongCommentMarkerTest, currently under development)
  2. Determine whether the bug is in any way a result of some interaction with Mandrake or TWiki (or at least, a better judgement of such than I can make)
  3. If the answer to the first point is yes, and the second is no, search the Mozilla Bugzilla to see if the bug is already reported, and, if not, report it.

This is something of an experiment -- I put in what I consider a (more than) reasonable amount of time to get this far. Others in the right position can carry the steps listed above forward at less cost (time) than I can. (As an example, if you have a later version of Mozilla installed, you can quickly view the test page and see if the problem still exists in that latest version.)

I'm not suggesting that any one person do all the steps above -- I'm suggesting that anyone take a step that is convenient to them and then add appropriate notes to the page. After a few people answer points 1 and 2, it will be appropriate for someone to carry on with step 3.

PS: The bug is that Mozilla 1.1 recognizes "--" as the HTML end of comment marker instead of (or perhaps in addition to) "-->".

  • TWiki version: 16 Jan 2003 on twiki.org
  • Perl version: "
  • Web server & version: "
  • Server OS: "
  • Web browser & version: Mozilla 1.1
  • Client OS: Linux (Mandrake 9.0)

-- RandyKramer - 16 Jan 2003

Resolution

Oops, stop the presses -- it turns out this is not a bug but is in accordance with the actual definition of HTML comment markers. Mozilla gets it right, IE gets it wrong. (BTW, it seems very strange to me, but for now, that's beside the point.) I got the following explanation from Tom Kennedy <T.Kennedy@seafloor.com> -- I'll quote one of the later paragraphs first:

And, I sort of understand why it is that way -- if you look at some HTML you may find statements like: <!ENTITY % HTML.Version "-//W3C//DTD HTML 4.01 Transitional//EN">. From this, I realize that something prefixed with <! is sort of an HTML command, thus another something ("--") is needed within such statements for comments to the command. Aside: Since simply enclosing some things (things that are not recognized as HTML markup within < > markers make them invisible to many browsers (all?) maybe that is an alternate comment markup which will serve my purposes. I may try this.

Oops, another gotcha / bug / anomaly that I will not explore at this time -- if I enclose the previous paragraph in "_"s to make it appear italic, the entire remainder of the document appears in italic.

One of the later paragraphs:

An HTML comment begins with "<!--", ends with "-->" and does not contain "--" or ">" anywhere in the comment.

Most of the email:

You're right, Mozilla is actually implementing the spec for comments. The rule is too strange for words, so I have included it below. Odd that apparently this goes back to SGML, but all the earlier browsers were able to tell comments just fine. This also explains why Mozilla doesn't let me comment out blocks of Twiki code that include the TWiki breakline (---). It turns out that hyphens must occur in multiples of 4 inside comments!

Info from http://www.htmlhelp.com/reference/wilbur/misc/comment.html follows:

HTML comments

Since HTML is officially an SGML application, the comment syntax used in HTML documents is actually the SGML comment syntax. Unfortunately this syntax is a bit unclear at first.

The definition of an SGML comment is basically as follows: A comment declaration starts with <!, followed by zero or more comments, followed by >. A comment starts and ends with "--", and does not contain any occurrence of "--". This means that the following are all legal SGML comments:

  1. <!-- Hello -->
  2. <!-- Hello -- -- Hello-->
  3. <!---->
  4. <!------ Hello -->
  5. <!>

Note that an "empty" comment tag, with just "--" characters, should always have a multiple of four "-" characters to be legal. (And yes, <!> is also a legal comment - it's the empty comment).

Not all HTML parsers get this right. For example, "<!------> hello-->" is a legal comment, as you can verify with the rule above. It is a comment tag with two comments; the first is empty and the second one contains "> hello". If you try it in a browser, you will find that the text is displayed on screen.

There are two possible reasons for this:

  1. The browser sees the ">" character and thinks the comment ends there.
  2. The browser sees the "-->" text and thinks the comment ends there.

There is also the problem with the "--" sequence. Some people have a habit of using things like "<!-------------->" as separators in their source. Unfortunately, in most cases, the number of "-" characters is not a multiple of four. This means that a browser who tries to get it right will actually get it wrong here and actually hide the rest of the document.

For this reason, use the following simple rule to compose valid and accepted comments:

An HTML comment begins with "<!--", ends with "-->" and does not contain "--" or ">" anywhere in the comment.

Contributors

WebForm
SupportStatus Select one...
Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2003-01-18 - RandyKramer
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.