Closed Bug 116321 Opened 18 years ago Closed 18 years ago

File extension overrides DOCTYPE


(SeaMonkey :: General, defect, minor)

Windows 2000
Not set


(Not tracked)



(Reporter: David, Assigned: asa)



(2 files)

XML Parsing Error: syntax error

is returned if the file extension is "XHTML" even if the DOCTYPE is

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

Mozilla 0.9.5
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.5) Gecko/20011213

The sample content validates at

Internet Explorer 6.0.2600 renders the content even if the file has an xhtml
extension.  This does not mean it's the right thing to do!

Sample content:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Some title</title>
	<p>Some HTML</p>
The server is probably picking up on the file extension and serving the document
with a MIME-type of application/xhtml+xml or text/xml.  Actual MIME headers
override HTTP headers specified in the document.  Do you have a testcase of this
online?  DOCTYPE sniffing only applies for documents within the text/html MIME-type.
Sorry, I should have mentioned that in this case I was opening the file 
directly from the file system by dragging it from Windows Explorer onto the 
render area of Mozilla.
Attached file An example XHTML File
I have explicitly set the content type to HTML when adding this attachment
Attached file The same example file
This has been submitted with auto-detect for the content-type
Both of the test attachments work fine as the content type has been explicitly
noted by BugZilla.  I'm not sure about what other tests I can perform as I don't
have control over a public web server for you to link to.
Have just tried this on IIS 5.  The MIME type is listed as application/xhtml+xml
as you would expect.  When connecting to the webserver I got the "What
application should I use?" dialog box.  This didn't happen when I loaded the
same file from the file system (I connected to the file system of the remote
machine to test remoting issues).

I've opened up my IIS Server for you to have a look (these are the same file):


Oh well, guess I'll re-build it in the morning!
OK, here's what I assume is happening.  The file on your local system has a
.xhtml extension.  When Mozilla sees the file extension, it assumes the document
will be XHTML, *and treats it as if it were XML, not HTML*, because not all
XHTML can be classified as text/html.  (Appendix C of XHTML 1.0).  So by the
time the parser gets to the DOCTYPE, the document is already loaded as XML, and
it throws an XML error.  DOCTYPE sniffing is an institution peculiar to
text/html or files identified as such (.html, .htm).

(And your webserver is now serving the .xhtml file as application/octet-stream,
And the browser won't start if I rename mozilla.exe into mozilla.txt --

XHTML is an XML markup.  We treat .xhtml as such from a filesystem.  Your file
is clearly not XHTML.  Why name it with that extension in the first place?  If
you drop that file onto any recent server, it will serve it with an XML
mimetype.  Isn't it safe for us to assume that it is XML as well?
URL: None
>>Why name it with that extension in the first place<<

It was an accident.

I can understand what you're saying and am happy to go with that approach.  I 
don't have enough familiarity with XHTML yet to know any better. As the file 
system doesn't indicate the MIME type, it's neccessary to make some assumptions 
and what you've detailed makes sense.

Thanks for your help.
Closed: 18 years ago
Resolution: --- → INVALID
Product: Browser → Seamonkey
You need to log in before you can comment on or make changes to this bug.