Opened 14 years ago
Closed 13 years ago
#18050 closed Bug (fixed)
CachedStaticFilesStorage eats @import statement
| Reported by: | anonymous | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.staticfiles | Version: | 1.4 |
| Severity: | Normal | Keywords: | CachedStaticFilesStorage css preprocessing @import |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Input:
@import '../../3rdparty/pt-sans-generated/stylesheet.css';
html, body {
padding: 0;
margin: 0;
background: transparent;
}
Output:
url("../../3rdparty/pt-sans-generated/stylesheet.cc11c6fa559e.css");
html, body {
padding: 0;
margin: 0;
background: transparent;
}
Without @import statement!
Problem located in:
class CachedFilesMixin(object):
patterns = (
("*.css", (
r"""(url\(['"]{0,1}\s*(.*?)["']{0,1}\))""",
r"""(@import\s*["']\s*(.*?)["'])""",
)),
)
last statement replace whole (@import…) construction with just url(). This quick fix solves a problem:
class FixedCachedFilesMixin(CachedFilesMixin):
patterns = (
("*.css", (
r"""(url\(['"]{0,1}\s*(.*?)["']{0,1}\))""",
r"""@import\s*(["']\s*(.*?)["'])""",
)),
)
class CachedStaticFilesStorage(CachedFilesMixin, StaticFilesStorage):
"""
A static file system storage backend which also saves
hashed copies of the files it saves.
"""
pass
But it is definitely a serious bug because @import is completely broken by default.
Change History (2)
comment:1 by , 14 years ago
| Severity: | Release blocker → Normal |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 13 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
In [3047981517ffa0c75c97f05446bd0d41865e323b]: