mirror of https://github.com/django/django.git
Fixed #26671 -- Made HashedFilesMixin ignore the 'chrome' scheme.
This commit is contained in:
parent
82be474efa
commit
08ed3cc6d1
|
@ -162,8 +162,8 @@ class HashedFilesMixin(object):
|
||||||
"""
|
"""
|
||||||
matched, url = matchobj.groups()
|
matched, url = matchobj.groups()
|
||||||
|
|
||||||
# Ignore absolute/protocol-relative, fragments and data-uri URLs.
|
# Ignore absolute/protocol-relative and data-uri URLs.
|
||||||
if url.startswith(('http:', 'https:', '//', '#', 'data:')):
|
if re.match(r'^[a-z]+:', url):
|
||||||
return matched
|
return matched
|
||||||
|
|
||||||
# Ignore absolute URLs that don't point to a static file (dynamic
|
# Ignore absolute URLs that don't point to a static file (dynamic
|
||||||
|
|
|
@ -3,6 +3,7 @@ body {
|
||||||
background: url("http:foobar");
|
background: url("http:foobar");
|
||||||
background: url("https:foobar");
|
background: url("https:foobar");
|
||||||
background: url("data:foobar");
|
background: url("data:foobar");
|
||||||
|
background: url("chrome:foobar");
|
||||||
background: url("//foobar");
|
background: url("//foobar");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,13 +53,14 @@ class TestHashedFiles(object):
|
||||||
|
|
||||||
def test_path_ignored_completely(self):
|
def test_path_ignored_completely(self):
|
||||||
relpath = self.hashed_file_path("cached/css/ignored.css")
|
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:
|
with storage.staticfiles_storage.open(relpath) as relfile:
|
||||||
content = relfile.read()
|
content = relfile.read()
|
||||||
self.assertIn(b'#foobar', content)
|
self.assertIn(b'#foobar', content)
|
||||||
self.assertIn(b'http:foobar', content)
|
self.assertIn(b'http:foobar', content)
|
||||||
self.assertIn(b'https:foobar', content)
|
self.assertIn(b'https:foobar', content)
|
||||||
self.assertIn(b'data:foobar', content)
|
self.assertIn(b'data:foobar', content)
|
||||||
|
self.assertIn(b'chrome:foobar', content)
|
||||||
self.assertIn(b'//foobar', content)
|
self.assertIn(b'//foobar', content)
|
||||||
|
|
||||||
def test_path_with_querystring(self):
|
def test_path_with_querystring(self):
|
||||||
|
|
Loading…
Reference in New Issue