Opened 6 years ago

Closed 6 years ago

#18487 closed Bug (fixed)

CachedStaticFilesStorage raises an exception when trying to deal with a url() starting with //

Reported by: Kit Sunde Owned by: Łukasz Balcerzak
Component: contrib.staticfiles Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no


We have a bunch of CSS that looks like this:

background: url(// left -125px repeat-x;

which it tries to deal with resulting in the following stack trace:

Traceback (most recent call last):
  File "src/city_nomads/", line 9, in <module>
  File "/Users/kitsunde/.virtualenvs/citynomads/lib/python2.7/site-packages/django/core/management/", line 443, in execute_from_command_line
  File "/Users/kitsunde/.virtualenvs/citynomads/lib/python2.7/site-packages/django/core/management/", line 382, in execute
  File "/Users/kitsunde/.virtualenvs/citynomads/lib/python2.7/site-packages/django/core/management/", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Users/kitsunde/.virtualenvs/citynomads/lib/python2.7/site-packages/django/core/management/", line 232, in execute
    output = self.handle(*args, **options)
  File "/Users/kitsunde/.virtualenvs/citynomads/lib/python2.7/site-packages/django/core/management/", line 371, in handle
    return self.handle_noargs(**options)
  File "/Users/kitsunde/.virtualenvs/citynomads/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/", line 163, in handle_noargs
    collected = self.collect()
  File "/Users/kitsunde/.virtualenvs/citynomads/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/", line 120, in collect
    for original_path, processed_path, processed in processor:
  File "/Users/kitsunde/.virtualenvs/citynomads/lib/python2.7/site-packages/django/contrib/staticfiles/", line 226, in post_process
    content = pattern.sub(converter, content)
  File "/Users/kitsunde/.virtualenvs/citynomads/lib/python2.7/site-packages/django/contrib/staticfiles/", line 167, in converter
    hashed_url = self.url(unquote(joined_result), force=True)
  File "/Users/kitsunde/.virtualenvs/citynomads/lib/python2.7/site-packages/django/contrib/staticfiles/", line 114, in url
    hashed_name = self.hashed_name(clean_name).replace('\\', '/')
  File "/Users/kitsunde/.virtualenvs/citynomads/lib/python2.7/site-packages/django/contrib/staticfiles/", line 74, in hashed_name
    (clean_name, self))
ValueError: The file 'unquote(joined_result' could not be found with < object at 0x109a86910>.

I think the expected behavior in this case would be for it to assume it's a http:// or https:// type URL and not attempt to open it.

Attachments (1)

ignore-paths-starting-with-double-slashes.diff (2.3 KB) - added by Łukasz Balcerzak 6 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 6 years ago by Luke Plant

Triage Stage: UnreviewedAccepted

comment:2 Changed 6 years ago by Łukasz Balcerzak

Owner: changed from nobody to Łukasz Balcerzak

Changed 6 years ago by Łukasz Balcerzak

comment:3 Changed 6 years ago by Łukasz Balcerzak

Has patch: set
Status: newassigned

comment:4 Changed 6 years ago by Jannis Leidel <jannis@…>

Resolution: fixed
Status: assignedclosed

In [1aa0d8ac4d3149fad6ebe80834d9e6f83021cf55]:

Fixed #18487 -- Made sure that protocol-relative URLs aren't processed by the cached staticfiles storage. Thanks to LukaszBalcerzak for the patch.

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