Comments with multiple dashes and no ending space fool the HTML parser




12 years ago
12 years ago


(Reporter: tegan, Unassigned)


Firefox Tracking Flags

(Not tracked)





12 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20070219 Firefox/
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20070219 Firefox/

HTML comments with multiple dashes and no ending space fool the HTML parser.

An example of a bad comment:
<!---------------------------------END HEADER ------------------------------------------>

Example of a good comment:
<!---------------------------------END HEADER ----------------------------------------- ->

The bad comment will cause the HTML parser to think everything below it is commented, until the next comment is started. Lots of web site developers use comments like this to signify sections of their site.

Reproducible: Always

Steps to Reproduce:
1. Create an HTML file
2. Wrap the contents in comments like the above "bad comment"
3. View the page. The page will be blank, and in View Source everything between the comments will be green (meaning commented out).
Actual Results:  
The HTML parser thinks that chunk of HTML is commented out, when it's not.

Expected Results:  
It should realize that the comment was ended correctly with a ->, even if there is no space preceding the ->, it's still a valid comment ending.

Comment 1

12 years ago
Updated the URL with a test page. You can go there to see the issue. You will notice the page is blank, and if you view the page source, you will see the page content (an unordered list) is commented out.

Comment 2

12 years ago
This looks like bug 233270 to me.  Please check you agree, and dupe if you do.

Comment 3

12 years ago
I agree it's a dupe, and will mark it as such, but I think the issue should be revisited. I understand compliance with SGML, but this isn't SGML, it's HTML and in this case it's XHTML. I understand standards conformance, but I think it can be taken to far. This is one of those cases, in my mind. As a developer, I can work around this, but it's a pain to train designers that "Hey, -- in a comment breaks FireFox and FireFox only, don't do it". I have marked it as a dupe.
Last Resolved: 12 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 233270
You need to log in before you can comment on or make changes to this bug.