Closed
Bug 40625
Opened 25 years ago
Closed 24 years ago
JS doesn't ignore --> in HTML (requires // -->) ; WAS: html comment in javascript block causes undefined symbols
Categories
(Core :: JavaScript Engine, defect, P3)
Tracking
()
People
(Reporter: sean, Assigned: rogerl)
References
Details
(Keywords: testcase, Whiteboard: [nsbeta2+][6/15])
Attachments
(2 files)
web developers commonly use html comments (<--) inside of script blocks hoping
to prevent the display of the script in some browsers. Mozilla appears to
treat html comments inside script blocks as code comments.
Will attach testcase.
Reporter | ||
Comment 1•25 years ago
|
||
Reporter | ||
Comment 2•25 years ago
|
||
added 4xp and nsbeta2 keywords.
Comment 3•25 years ago
|
||
changing --> to //--> in the testcase fixes the problem.
see also http://www.w3.org/TR/html4/interact/scripts.html#h-18.3.2
The page appears to operate correctly (when compared to nav4). Can someone tell
me what the problem actually is?
Whiteboard: [NEED INFO]
Reporter | ||
Comment 5•25 years ago
|
||
Type anything into the text field. Clicking on resetForm1 clears the field,
but resetForm2 doesn't (with a pull from the tip 5/30). In nav4 and IE,
resetForm2 does clear the field (even though the HTML comment is not js
commented).
Comment 6•25 years ago
|
||
The issue:
1) JS spec says that <!-- should be treated as a JavaScript comment, and that
<!-- and //--> should be used to enclose JavaScript code to prevent non-JS
browsers and browsers with JS turned off from displaying script as content.
(Note the mandatory // JavaScript comment in the closer.) Nav4/IE5/Moz5-15 all
handle this perfectly, & I'm attaching a second testcase demonstrating that.
2) Reporter has discovered in his testcase (and I've confirmed) that Nav4 and
IE5 both had a quirk in which they tolerated the use of --> as the closer
instead of //-->. This is not correct JavaScript syntax, but since Nav4 and IE5
both tolerated it, I think we can safely assume there's tons of JS out there
that makes this mistake, and that we had better tolerate this in Moz in quirks
mode.
Setting to [nsbeta2+][6/15]. Reassigning to harishd@netscape.com since this is
a parser quirks issue.
Assignee: jst → harishd
Whiteboard: [NEED INFO] → [nsbeta2+][6/15]
Comment 7•25 years ago
|
||
This is certainly not a parser issue. As far as parser is concerned contents
within SCRIPT are CDATA. However, in quirks mode we do scan for '-->' when
'<!--' is encountered. But, it's not up to the parser to resolve JS errors,i.e.,
the parser cannot insert '//' ( for this bug ) to solve the problem. This
problem should be addressed in the JS engine. Over to Roger.
Assignee: harishd → rogerl
*** Bug 36122 has been marked as a duplicate of this bug. ***
Comment 10•25 years ago
|
||
I get an error when I load the first attachment
http://bugzilla.mozilla.org/showattachment.cgi?attach_id=9160
into 4.7
JavaScript Error:
http://bugzilla.mozilla.org/showattachment.cgi?attach_id=9160, line
14:
syntax error.
-->
..^
And I am sure I have encountered various pages (notable from microsoft.com) with
the same error where NN4 always showed that error. So I don't think we can say
NN4 tolerates the error. You might get lucky that the function already parsed is
around after the error stops further js interpretation. But I am sure I have
encountered various pages where NN4 first reported that error and then further
errors occured when trying to access objects defined in that incorrectly closed
script block. So I think it is an IE only quirk. And mozilla doesn't need to
follow it.
Comment 11•24 years ago
|
||
*** This bug has been marked as a duplicate of 31255 ***
Status: NEW → RESOLVED
Closed: 24 years ago
Component: DOM Level 0 → Javascript Engine
Resolution: --- → DUPLICATE
Summary: html comment in javascript block causes undefined symbols → JS doesn't ignore --> in HTML (requires // -->) ; WAS: html comment in javascript block causes undefined symbols
You need to log in
before you can comment on or make changes to this bug.
Description
•