Incorrect interpretation of CSS @import

Bug #1930922 reported by pepak
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
calibre
Fix Released
Undecided
Unassigned

Bug Description

Calibre 5.xx (all versions up to at least 5.20) incorrectly interprets @import url(...) rules in CSS sheets (when relative URLs are used. According to W3 ( http://www.w3.org/TR/REC-CSS1/#url ), partial (e.g. relative) URLs should be interpreted "relative to the source of the style sheet, not relative to the document". Calibre 5.xx does not do that - I wasn't able to verify it exactly, but the observed behavior is consistent with Calibre interpreting relative urls as relative to the first CSS in the chain. Calibre 4.xx used a correct interpretation.

Attached example demonstrates the problem. We have the following files:

test.htm
test.css
a/test.css
a/b/test.css

Test.htm loads a/b/test.css using <link rel="stylesheet" href="a/b/test.css" type="text/css"/> and as far as I can tell, Calibre can process that correctly. a/b/test.css then loads a/test.css using @import url('../test.css'), and this also gets interpreted correctly by Calibre. Then a/test.css tries to load test.css using @import url('../test.css') and this will crash Calibre (but not a browser). As far as I can tell, the last @import rule will incorrectly try to load a/test.css again, and again, and again until it exhausts the stack.

I reported a similar error some time ago ( https://bugs.launchpad.net/calibre/+bug/1901278 ) and that received a fix, but apparently it was only a partial fix - it resolved the specific case described in that bugreport, but the incorrect behavior remained.

Revision history for this message
pepak (liunchpad-net) wrote :
Revision history for this message
Kovid Goyal (kovid) wrote : Fixed in master

Fixed in branch master. The fix will be in the next release. calibre is usually released every alternate Friday.

 status fixreleased

Changed in calibre:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.