Status

()

Firefox
General
RESOLVED DUPLICATE of bug 338810
12 years ago
12 years ago

People

(Reporter: Darren Robinson, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

12 years ago
User-Agent:       Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3
Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3

There is an interesting error with the comment parsing within firefox; having read the details about 'valid' and 'invalid' comments in SGML/XML/HTML i am a little puzzled by the following:

i wrote a page and later was required to remove a script section for testing; the original script looked as follows:

<script language="JavaScript" type="text/javascript">
<!--
  // script content was here
//-->
</script>

to temporarily remove the script (for testing) i used the following:
<!--script language="JavaScript" type="text/javascript">
<!--
  // script content was here
//-->
</script-->

but soon found that many browsers see this as:
markup start [<!]
comment start [--]
comment content [script language="JavaScript" type="text/javascript"><!--// script content was here//]
comment end [--]
markup end [>]
markup start [<]
markup [/script]
erronious comment end [--]
markup end [>]

the last </script> is ignored as invalid markup (closed tag no start)

in order to combat this (for asthetic reasons - it not being significant to interpretation) i added the comment start <!-- to the begining of the script closing tag to produce the following:

markup start [<!]
comment start [--]
comment content [script language="JavaScript" type="text/javascript"><!--// script content was here//]
comment end [--]
markup end [>]
markup start [<!]
comment start [--]
comment content [/script]
comment end [--]
markup end [>]

after reading the documentation this MAY produce errors as it implies:
markup start [<!]
comment start [--]
comment content [script language="JavaScript" type="text/javascript"><!]
comment end [--]
markup [// script content was here//]
comment start [--]
comment content [><!]
comment end [--]
markup [/script]
comment start [--]
comment content [>]
...

the comment not being closed?!

firefox either interprets the original as follows:
markup start [<!]
comment start [--]
comment content [script language="JavaScript" type="text/javascript"><!--// script content was here//--></script]
comment end [--]
markup end [>]


the revised markup would therefore be interpreted by firefox as:
markup start [<!]
comment start [--]
comment content [script language="JavaScript" type="text/javascript"><!--// script content was here//--><!--/script]
comment end [--]
markup end [>]

which it isnt (an therefore i conclude this is NOT how firefox interprets comments)

the more probably interpretation for ther original by firefox is (through experimentation):
markup start [<!]
comment start [--]
comment content [script language="JavaScript" type="text/javascript"><!]
comment start (second level) [--]
comment content (second level) [// script content was here//]
comment end (second level) [--]
comment content [></script]
comment end [--]
markup end [>]

which means the following would be the result from the revised markup:

markup start [<!]
comment start [--]
comment content [script language="JavaScript" type="text/javascript"><!]
comment start (second level) [--]
comment content (second level) [// script content was here//]
comment end (second level) [--]
comment content [><!]
comment end [--]
markup [/script]
comment start [--]
comment content [>]
...

which is what is observed. this can be demonstrated by looking at the source as firefox sees it. comments in green match the above description.

However, this is still incorrect as there is no nesting of comments in HTML/XML/SGML

the correct interpretation is:
markup start [<!]
comment start [--]
comment content [script language="JavaScript" type="text/javascript"><!]
comment end [--]
markup [// script content was here//]
comment start [--]
comment content [></script]
comment end [--]
markup end [>]

which means the following would be the result from the revised markup:

markup start [<!]
comment start [--]
comment content [script language="JavaScript" type="text/javascript"><!]
comment end [--]
markup [// script content was here//]
comment start [--]
comment content [><!]
comment end [--]
markup [/script]
comment start [--]
comment content [>]
...

Reproducible: Always

*** This bug has been marked as a duplicate of 338810 ***
Status: UNCONFIRMED → RESOLVED
Last Resolved: 12 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.