Closed Bug 306472 Opened 19 years ago Closed 19 years ago

CSS file load fails if a valid !DOCTYPE, and URL contains an underscore

Categories

(SeaMonkey :: General, defect)

x86
Windows 98
defect
Not set
major

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: r.e.harvey, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.7.7) Gecko/20050414
Build Identifier: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.7.7) Gecko/20050414

With Mozilla 1.7.7 on Win98SE, if you use no !DOCTYPE, or an incomplete
!DOCTYPE, Mozilla will correctly load an external style sheet using any standard
method.

If you use a valid !DOCTYPE, such as this:

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

And your URL contains an underscore, such as this:

 http://ourworld.compuserve.com/homepages/r_harvey/index.htm

The external CSS file will not load. When that file fails to load, any JS file
that is listed later in the HTML, will also fail to load.

Styles defined within the HTML file are interpreted correctly, and if you load a
JS file after those loacal styles, it will load correctly.


Reproducible: Always

Steps to Reproduce:
1. Create a URL and an HTML file, and a CSS file in the same location; the URL
must contain an underscore character (ANSI character 95).
2. Open Mozilla 1.7.7 and view that HTML page
3.

Actual Results:  
Page is displayed without any CSS formatting. If there is a JS file, it will not
load, either

Expected Results:  
Apparently the software reserves the underscore character ("_") for another
purpose (to represent a space, perhaps?), when it should not. The character is a
valid part of a URL in some environments.
Can you post an example page that fails?  But given the information you present,
this sounds like proper behavior.  Without a valid doctype, the layout engine
runs in 'quirks' mode, which ignores some rules.  With a valid doctype, it runs
in strict mode.  See http://www.mozilla.org/docs/web-developer/quirks/

Also take a look at the JavaScript Console, you'll probably see a message there
explaining what is wrong.
Here is a test file that shows the problem:

http://ourworld.compuserve.com/homepages/r_harvey/doctypecss.htm

Here is the error message in the JavaScript console:

Error: The stylesheet [url] was not loaded because its MIME type,
"application/octet-stream", is not "text/css".

While the external style sheet does not load, it seems that in this example the
JS file loads when there is a local style defined, but not when there is no
local style. That is not always the case.
The server is sending the CSS file as application/octet-stream, so you'll need
to take that up with Compuserve.

Can you post an example where the external Javascript isn't working?
It works if the file is local, and it works with other browsers, including Opera
7 and IE5.5, and it works in Mozilla if the style is within the HTML document.

I suppose Quirks mode allows Mozilla to recognize application/octet-stream as
valid CSS, but strict does not. It would seem that Mozilla could assume that the
file type is what the HTML says it is, since there would be nothing executable
in a style sheet, anyway. There's really no work around but to write
non-compliant HTML in order to work correctly with Mozilla. Perhaps somebody,
Mozilla or CompuServe, will recognize it as text, if it has an extension that it
likes.

The only time the JavaScript fails to load is if the CSS fails, too. If Mozilla
won't load the style sheet, because it thinks it's application/octet-stream, it
will likely get the JS file the same way.
CompuServe has known about the issue since at least 1999, and they've not
corrected it.

So, the work-around, if Mozilla isn't going to ease its requirements, is to
place the whole style sheet in the HTML document, or don't use a !DOCTYPE, and
let Mozilla render in quirks mode (the page still validates as
standards-compliant, with a minor warning about no !DOCTYPE).
Resolving invalid, since it's a server issue.

There are a few similar bugs if you want to go looking.  General reasoning given
for not considering this a bug: Mozilla should respect the MIME type sent by the
server.  Style sheets can conceptually be in multiple languages, of which CSS is
just one.  So if the server returns a style sheet that isn't CSS, but in some
other unsupported language, the browser has to ignore it.

This isn't useful in a lot of legacy cases, and that's why quirks mode exists. 
So if you can't use strict mode due to a server misconfiguration, then take
advantage of quirks (though be aware of the other quirks mode differences).
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.