Closed Bug 153753 Opened 22 years ago Closed 20 years ago

HTML STYLE elements should be closed by first </ sequence

Categories

(Core :: DOM: HTML Parser, defect)

defect
Not set
normal

Tracking

()

VERIFIED WONTFIX

People

(Reporter: bugmail, Unassigned)

References

(Blocks 1 open bug, )

Details

(Keywords: testcase)

Attachments

(2 files)

According to the HTML 4.0.1 specification, Section 6.2, the STYLE element should
be closed by the first encountered </ sequence, not merely the first encountered
</STYLE> sequence. Only in valid documents will the latter sequence be encountered.
Blocks: 153699
HTMLParser bug.  We might want to consider fixing for strict mode (perhaps even
for quirks mode for stylesheets, but it would definitely break scripts).
Assignee: dbaron → harishd
Component: Style System → Parser
QA Contact: ian → moied
HTML 4 reference: [http://www.w3.org/TR/html401/types.html#h-6.2].
Summary: HTML STYLE element should be closed by any </ sequence → HTML STYLE and SCRIPT elements should be closed by any </ sequence
Summary: HTML STYLE and SCRIPT elements should be closed by any </ sequence → HTML STYLE and SCRIPT elements should be closed by first </ sequence
Attached file STYLE element testcase
A quick testcase for the STYLE element. Note the first statement (on 'div')
following the </foo> is ignored, as expected, but the following statement (on
'p') is not ignored.
A quick testcase of the SCRIPT element. It generates a syntax error on the JS
Console, so the effective behavior is as described. Should the parser simply
interpret the </foo> as the end of the script, though, and not send it to the
JS engine?
Keywords: testcase
<script>
document.write('<a>text</a>');
</script>

is very common and is why we do not do this per spec at the moment... Doing this
for scripts would break a large fraction of pages out there....

I agree that we should do this for <style>, though....
Status: UNCONFIRMED → NEW
Ever confirmed: true
5 months later...

First, this bug should be platform All/All rather than Mac/OSX. I tested Win98
release 1.2.1 and got the same results.

Second, the testcases should at least TRY to validate. There are ways to place a
</ sequence in a style or script that would otherwise be valid, rather than
throwing an arbitary </foo> in the middle:

script testcase: document.writeln("<i>foo</i>")
style testcase: div:before { content: "<i>foo</i>" }

Third, I think the script side of this bug should be WONTFIX, because it would
break way too many websites.
OS: MacOS X → All
Hardware: Macintosh → All
Should the SCRIPT part be implemented in Standards-compliance mode only, then,
as mentioned in comment 1?
If you're willing to fork some of the most fragile code in the app and create a
variant that will receive almost no testing and hence will break often, sure it
could be done.  Just a matter of time and priorities.  ;)
Boris, this actually shouldn't be too hard to implement.

Is </ common in <style> tags? While the testcase in comment 6 is points to a
quirks-only fix, I wonder if we should just follow the spec in all cases.

Should I bother (and if I should, should I wait until an alpha cycle)?
Assignee: harishd → parser
QA Contact: moied → mrbkap
Summary: HTML STYLE and SCRIPT elements should be closed by first </ sequence → HTML STYLE elements should be closed by first </ sequence
See comment 1.  Fixing this for <style> may be OK, but fixing it for <script>
will absolutely break pages; I'm against doing it in any mode.

The only way <style> will contain a "</" is if it's present in one of the
strings in the stylesheet...  Probably rare, since strings in stylesheets are
somewhat rare.  But still it may be worth wontfixing this on the basic premise
that absolutely no UA implements this part of HTML (assuming that's true).
Since no other browser implements the spec. in this way, this bug is WONTFIX.
There is a message
(http://listserver.dreamhost.com/pipermail/whatwg-whatwg.org/2005-January/002993.html)
on the WHATWG mailing list calling this part of the HTML spec. into question,
and (even in standards mode) this fix would only cause web sites grief.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → WONTFIX
*** Bug 150323 has been marked as a duplicate of this bug. ***
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: