Opened 9 years ago

Closed 8 years ago

#26671 closed Bug (fixed)

`ManifestStaticFilesStorage` does not work for CSS with URLs including `chrome` scheme

Reported by: Tai Lee Owned by: Deepak Sattiraju
Component: contrib.staticfiles Version: dev
Severity: Normal Keywords: ManifestStaticFilesStorage chrome scheme
Cc: dsattiraju249@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

One of the 3rd party CSS files used by our project contains CSS like this:

.sourceRow[exe_line="true"] > .sourceLine {
    background-image: url(chrome://firebug/skin/exe.png);
    color: #000000;
}

This causes ManifestStaticFilesStorage to crash with:

Post-processing 'lodash/vendor/firebug-lite/skin/xp/debugger.css' failed!
Traceback (most recent call last):
  File "./manage.py", line 23, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 346, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 394, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 445, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 168, in handle
    collected = self.collect()
  File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 120, in collect
    raise processed
ValueError: The file 'lodash/vendor/firebug-lite/skin/xp/chrome:/firebug/skin/exe.png' could not be found with <django.contrib.staticfiles.storage.ManifestStaticFilesStorage object at 0x7faab0f72950>.

Looks like this .startswith() call needs to change to a regex, or at least include a few more known schemes:

https://github.com/django/django/blob/edcecaf0dea718a8fb216df478df0d151a9ba04d/django/contrib/staticfiles/storage.py#L166

            if url.startswith(('http:', 'https:', '//', '#', 'data:')):
                return matched

Something like this should do the trick (very briefly tested in interactive shell):

            if re.match(r'(?i)([a-z]+://|//|#|data:)', url):
                return matched

Change History (6)

comment:1 by Tim Graham, 9 years ago

Component: Core (Management commands)contrib.staticfiles
Triage Stage: UnreviewedAccepted

comment:2 by Simon Charette, 8 years ago

Has patch: set
Needs tests: set
Patch needs improvement: set
Version: 1.9master
Version 0, edited 8 years ago by Simon Charette (next)

comment:3 by Deepak Sattiraju, 8 years ago

Cc: dsattiraju249@… added
Owner: changed from nobody to Deepak Sattiraju
Status: newassigned

comment:4 by Tim Graham, 8 years ago

Needs tests: unset

Updated PR with a few comments for improvement.

comment:5 by Tim Graham, 8 years ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:6 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: assignedclosed

In 08ed3cc6:

Fixed #26671 -- Made HashedFilesMixin ignore the 'chrome' scheme.

Note: See TracTickets for help on using tickets.
Back to Top