This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 6978 - Mark eof-terminated script elements as malformed
Summary: Mark eof-terminated script elements as malformed
Status: VERIFIED NEEDSINFO
Alias: None
Product: HTML WG
Classification: Unclassified
Component: pre-LC1 HTML5 spec (editor: Ian Hickson) (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
URL: http://software.hixie.ch/utilities/js...
Whiteboard:
Keywords: NoReply
Depends on:
Blocks:
 
Reported: 2009-05-29 11:58 UTC by Henri Sivonen
Modified: 2010-10-04 14:45 UTC (History)
4 users (show)

See Also:


Attachments

Description Henri Sivonen 2009-05-29 11:58:49 UTC
When the tree builder sees an EOF, it should mark all HTML and SVG script elements on the stack (SVG makes it possible to have more than one) as malformed in the DOM. Then the serialization algorithm should check the malformedness flag and omit the end tag of the <script> element if the element has been marked malformed. This way, the malformedness round-trips, so serializing and reparsing doesn't make a malformed script run.

http://software.hixie.ch/utilities/js/live-dom-viewer/saved/123 shows that Firefox and Opera do this.
Comment 1 Ian 'Hixie' Hickson 2009-05-29 18:48:44 UTC
How should it handle such elements when they're not at the "end" of the document?
Comment 2 Simon Pieters 2009-06-02 08:49:07 UTC
The same as when they are at the end at the document.

If you append a text node "//" and another script element after the "malformed" script element, the malformed script would run after round-tripping.
Comment 3 Henri Sivonen 2009-06-02 08:52:33 UTC
For reference, the Gecko implementation of what zcorpan says is
http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsHTMLContentSerializer.cpp#336
Comment 4 Henri Sivonen 2009-06-02 11:16:14 UTC
CVS blame points to https://bugzilla.mozilla.org/show_bug.cgi?id=305873

The hack works for serializing the whole document through Save As... Complete.

The hack may fail if the page modified its own DOM via another script that wasn't malformed.
Comment 5 Ian 'Hixie' Hickson 2009-06-26 08:47:48 UTC
This seems very dubious to me. Wouldn't a better solution be to do something like set a bogus type="" on that <script>, like text/plain, or remove any text nodes in that script, or comment out the script, or something?
Comment 6 Maciej Stachowiak 2010-03-14 14:48:13 UTC
This bug predates the HTML Working Group Decision Policy.

If you are satisfied with the resolution of this bug, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
  http://dev.w3.org/html5/decision-policy/decision-policy.html

This bug is now being moved to VERIFIED. Please respond within two weeks. If this bug is not closed, reopened or escalated within two weeks, it may be marked as NoReply and will no longer be considered a pending comment.