0.9.6 doesn't interpret style sheets from <link rel>-tag




CSS Parsing and Computation
17 years ago
17 years ago


(Reporter: Matthias Hensler, Assigned: dbaron)



Firefox Tracking Flags

(Not tracked)



(3 attachments)



17 years ago
This problem was introduced with Mozilla 0.9.6, it wasn't there in the previous

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="http://www.w3.org/1999/xhtml">
<title>Test with CSS 2</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<p class="navbar"><span class="navbarinfo">Home</span></p>

The file style.css looks like this:
body { background-color:#ffffff; font-family:Helvetica,Arial,sans-serif;
color:#000000; font-size:12px; }
.navbar { background-color:#ededed; font-size:10px; color:#000000; }            
.navbaritem { background-color:#e0e0e0; color:#0d0d0d; font-weight:bold; }

when opening the page, the browser loads the style-sheet (I see this in my
access-log from apache) but does not interpret it, just default colors black and
white are used, instead of the background-colors und fonts defined in the
stylesheet. However this worked fine with the older Mozilla versions.

I tried to switch to Transitional instead of Strict, and left out the
XML-things, but it didn't change anything. However, if I use inline-CSS
everything works.

Many sites which looked ok with 0.9.5, doesn't look good any longer, because the
style-sheet is not used.
This is working fine for me with the attached testcase (which is just the HTML
and CSS originally pasted into the bug).

Is there a site "in the wild" where this happening?  Does the stylesheet contain
_anything_ (especially comments) other than the text you pasted in this bug?

Comment 4

17 years ago
Created attachment 60942 [details]
Style-Sheet which reproduces the problem

Well, I tracked down the problem. Seems the problem is not the <link rel>-tag,
but the style-sheet itself. Since I use the same style-sheet with more or less
extensions the problem occured on every page.

If a comment line contains an umlaut (eg "ü") the style-sheet is not
interpreted (although it worked with 0.9.5 and earlier).

The attached style-sheet reproduces the problem. If you cut the line

 * 2001/11/17 - Matthias Hensler: Hovers für Selects und Submits

or just the "ü" in "für" it works well.

Should be trivial to fix this.


17 years ago
Summary: 0.9.6 doesn't intrepret style sheets from <link rel>-tag → 0.9.6 doesn't interpret style sheets from <link rel>-tag
Yep.  That xhtml page is encoded as UTF-8.  The stylesheet contains a character
that is not a valid UTF-8 character, so decoding the sheet fails.  Yes, the
behavior of using the character coding of the document to decode the sheet is
new since 0.9.5 (before we defaulted to ISO-8859-1 instead of the document
encoding, and the character in question _is_ valid in ISO-8859-1).

This bug _is_ going to be "fixed" (we're going to start ignoring decoding errors
eventually) but in some cases you may actually get incorrect results if your
sheet is decoded using the wrong encoding.

What you should do to make sure this is never a problem is put:

@charset "ISO-8851-1";

as the first thing in your stylesheet, before any comments, rules, or
whitespace.  That will make sure the sheet is always decoded as ISO-8859-1 by
any browser which claims to support CSS.

see bug 106843 for details.

*** This bug has been marked as a duplicate of 107790 ***
Last Resolved: 17 years ago
Resolution: --- → DUPLICATE
> @charset "ISO-8851-1";

I meant 

@charset "ISO-8859-1";


Comment 7

17 years ago
Thanks alot for tracking this down. When I specify the encoding in the
style-sheet everything works fine. I just wonder why the translation does not
fail if I include the style-sheet inline?

Anyway, thanks for your help and work. Sorry to bother with this problem which
was actually my fault.
Inline sheets are decoded together with the whole document by the HTML parser. 
This has a workaround built in to deal with this issue, since it apparently pops
up a lot in HTML pages.

external sheets are decoded in the CSS loader....  The bug I marked this a
duplicate of is the bug on being able to skip decoding errors without writing
cludgey workarounds.  Once that's fixed, the CSS loader can use that, as can the
HTML parser.
You need to log in before you can comment on or make changes to this bug.