If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

self closing <script/> tags not handled properly in XHTML

RESOLVED INVALID

Status

()

Firefox
General
--
major
RESOLVED INVALID
7 years ago
7 years ago

People

(Reporter: matteo sisti sette, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

7 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.12) Gecko/20101027 Ubuntu/10.04 (lucid) Firefox/3.6.12
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.12) Gecko/20101027 Ubuntu/10.04 (lucid) Firefox/3.6.12

If a XHTML page contains a self-closing script tag such as:

<script type="text/javascript" src="myscript.js" />

the rest of the page won't be handled correctly, even if the doctype declaration properly identifies the page as XHTML. 

By changing the same line to <script ...></script> it is handled correctly. Both form should be PERFECTLY equivalent at ALL effects in XHTML.

This probably affects also other tags.

I think all browsers share this same bug, but that's not a reason not to fix it. The same XHTML code validates properly on W3C validators, so it should be handled properly by Firefox, no excuse. It is XHTML, it is declared as XHTML, it should be handled as XHTML.

Reproducible: Always

Comment 1

7 years ago
You are presumably serving the page with a mime type of text/html rather than an xhtml mime type. If you fix this it will work.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → INVALID
(Reporter)

Comment 2

7 years ago
Yes, but it also happens when you open the file locally from a file on the filesystem: in that case there is no serving at all and no mime type whatsoever. Which shows once more that relying on the http headers to decide how to parse the html (when there is a DOCTYPE declaration for that) is an error in the first place.
(Reporter)

Updated

7 years ago
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---

Comment 3

7 years ago
change the extension to .xhtml in that case. We can't use the doctype as we need to choose whether to use the html or xml parser to parse it so what parser would we read the DOCTYPE with?
Status: UNCONFIRMED → RESOLVED
Last Resolved: 7 years ago7 years ago
Resolution: --- → INVALID
(Reporter)

Comment 4

7 years ago
" We can't use the doctype as we
need to choose whether to use the html or xml parser to parse it so what parser
would we read the DOCTYPE with?"

It doesn't matter: the DOCTYPE has the same syntax in both cases, doesn't it?? 

Following your reasoning, an XML parser couldn't use the <?XML ... ecnoding=...> declaration to determine the character encoding, because what encoding would we decode the <?XML> declaration with?

Comment 5

7 years ago
(In reply to comment #4)
> 
> It doesn't matter: the DOCTYPE has the same syntax in both cases, doesn't it?? 

It does matter as we need to instantiate a parser and set it consuming the document.

> 
> Following your reasoning, an XML parser couldn't use the <?XML ...
> ecnoding=...> declaration to determine the character encoding, because what
> encoding would we decode the <?XML> declaration with?

The encoding text does not contain characters outside a well known limited set so we can parse it without knowing the encoding.
(Reporter)

Comment 6

7 years ago
Exactly, and the DOCTYPE obeys to a well known syntax that is common to both HTML and XHTML so one could parse it without knowing whether the document is HTML or XHTML. After parsing only the doctype one could instantiate the parser and start again.

Anyway you're right, the real problem is another one, and not related to firefox. Serving it as xml+xhtml (and naming it with .xhtml extension if it is intended for being used locally) actually _is_ the solution, except that Internet Explorer just won't parse xhtml at all. So one is practically obliged to serve xhtml as text/html. Which is a shame, but it is solely Internet Explorer's fault.

Comment 7

7 years ago
Problem also exists for <textarea/> and <iframe/> tags.

text/xhtml doesn't work: firefox asks to save file

application/xhtml+xml doesn't work either: firefox opens the file in the XML explorer, rather than displaying it as a web page...

I guess that means that we should stick to HTML 4, and forget about XHTML...

Comment 8

7 years ago
Sorry, actually it does work, but you also need to specify a namespace with your html tag:

<html xmlns="http://www.w3.org/1999/xhtml">

Strangely enough even with just <html>, it validates just fine in Html Validator...

... and the fact that application/xhtml+xml breaks Internet Exploder could actually be seen as a feature :^)
You need to log in before you can comment on or make changes to this bug.