Opened 12 years ago

Closed 12 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

Description

We have a bunch of CSS that looks like this:

background: url(//city-nomads.s3.amazonaws.com/v3-layout/header_bg_sprite.png) 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/manage.py", line 9, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/kitsunde/.virtualenvs/citynomads/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/Users/kitsunde/.virtualenvs/citynomads/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/kitsunde/.virtualenvs/citynomads/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Users/kitsunde/.virtualenvs/citynomads/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/Users/kitsunde/.virtualenvs/citynomads/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle
    return self.handle_noargs(**options)
  File "/Users/kitsunde/.virtualenvs/citynomads/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 163, in handle_noargs
    collected = self.collect()
  File "/Users/kitsunde/.virtualenvs/citynomads/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", 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/storage.py", line 226, in post_process
    content = pattern.sub(converter, content)
  File "/Users/kitsunde/.virtualenvs/citynomads/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", 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/storage.py", 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/storage.py", line 74, in hashed_name
    (clean_name, self))
ValueError: The file 'unquote(joined_result' could not be found with <django.contrib.staticfiles.storage.CachedStaticFilesStorage 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 12 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 by Luke Plant, 12 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Łukasz Balcerzak, 12 years ago

Owner: changed from nobody to Łukasz Balcerzak

by Łukasz Balcerzak, 12 years ago

comment:3 by Łukasz Balcerzak, 12 years ago

Has patch: set
Status: newassigned

comment:4 by Jannis Leidel <jannis@…>, 12 years ago

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