#18050: CachedStaticFilesStorage eats @import statement
-------------------------+-------------------------------------------------
     Reporter:           |      Owner:  nobody
  anonymous              |     Status:  new
         Type:  Bug      |    Version:  1.4
    Component:           |   Keywords:  CachedStaticFilesStorage css
  contrib.staticfiles    |  preprocessing @import
     Severity:  Release  |  Has patch:  0
  blocker                |      UI/UX:  0
 Triage Stage:           |
  Unreviewed             |
Easy pickings:  0        |
-------------------------+-------------------------------------------------
 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.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18050>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to