diff options
| author | Andrew Nester <andrew.nester.dev@gmail.com> | 2016-07-12 15:20:39 +0300 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-07-12 08:20:39 -0400 |
| commit | 08ed3cc6d160d0d864ff687db9a62959a86e7372 (patch) | |
| tree | 3bcef21414898c0b38cee550bf40c29b10cc5697 | |
| parent | 82be474efa81e5f2e127d711045a2ec06b206a8e (diff) | |
Fixed #26671 -- Made HashedFilesMixin ignore the 'chrome' scheme.
| -rw-r--r-- | django/contrib/staticfiles/storage.py | 4 | ||||
| -rw-r--r-- | tests/staticfiles_tests/project/documents/cached/css/ignored.css | 1 | ||||
| -rw-r--r-- | tests/staticfiles_tests/test_storage.py | 3 |
3 files changed, 5 insertions, 3 deletions
diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py index 0909f51724..d59a9cc122 100644 --- a/django/contrib/staticfiles/storage.py +++ b/django/contrib/staticfiles/storage.py @@ -162,8 +162,8 @@ class HashedFilesMixin(object): """ matched, url = matchobj.groups() - # Ignore absolute/protocol-relative, fragments and data-uri URLs. - if url.startswith(('http:', 'https:', '//', '#', 'data:')): + # Ignore absolute/protocol-relative and data-uri URLs. + if re.match(r'^[a-z]+:', url): return matched # Ignore absolute URLs that don't point to a static file (dynamic diff --git a/tests/staticfiles_tests/project/documents/cached/css/ignored.css b/tests/staticfiles_tests/project/documents/cached/css/ignored.css index fe7b022215..83b1d5ebf8 100644 --- a/tests/staticfiles_tests/project/documents/cached/css/ignored.css +++ b/tests/staticfiles_tests/project/documents/cached/css/ignored.css @@ -3,6 +3,7 @@ body { background: url("http:foobar"); background: url("https:foobar"); background: url("data:foobar"); + background: url("chrome:foobar"); background: url("//foobar"); } diff --git a/tests/staticfiles_tests/test_storage.py b/tests/staticfiles_tests/test_storage.py index 91774cf472..5298a287fd 100644 --- a/tests/staticfiles_tests/test_storage.py +++ b/tests/staticfiles_tests/test_storage.py @@ -53,13 +53,14 @@ class TestHashedFiles(object): def test_path_ignored_completely(self): relpath = self.hashed_file_path("cached/css/ignored.css") - self.assertEqual(relpath, "cached/css/ignored.6c77f2643390.css") + self.assertEqual(relpath, "cached/css/ignored.554da52152af.css") with storage.staticfiles_storage.open(relpath) as relfile: content = relfile.read() self.assertIn(b'#foobar', content) self.assertIn(b'http:foobar', content) self.assertIn(b'https:foobar', content) self.assertIn(b'data:foobar', content) + self.assertIn(b'chrome:foobar', content) self.assertIn(b'//foobar', content) def test_path_with_querystring(self): |
