1
0
mirror of https://github.com/django/django.git synced 2025-06-08 13:09:13 +00:00

Fixed #36348 -- Fixed handling multiple nested url()s in ManifestStaticFilesStorage.

Signed-off-by: Samuel Cormier-Iijima <samuel@cormier-iijima.com>
This commit is contained in:
Samuel Cormier-Iijima 2025-04-22 22:00:20 -04:00 committed by Sarah Boyce
parent 994dc6d8a1
commit 1ba5fe19ca
3 changed files with 12 additions and 1 deletions

View File

@ -80,7 +80,8 @@ class HashedFilesMixin:
(
"*.css",
(
r"""(?P<matched>url\(['"]{0,1}\s*(?P<url>.*?)["']{0,1}\))""",
r"""(?P<matched>url\((?P<quote>['"]{0,1})"""
r"""\s*(?P<url>.*?)(?P=quote)\))""",
(
r"""(?P<matched>@import\s*["']\s*(?P<url>.*?)["'])""",
"""@import url("%(url)s")""",

View File

@ -0,0 +1,3 @@
#example {
background-image: url("data:image/svg+xml,url(%23b) url(%23c)");
}

View File

@ -235,6 +235,13 @@ class TestHashedFiles:
self.assertIn(b"other.d41d8cd98f00.css", content)
self.assertPostCondition()
def test_css_data_uri_with_nested_url(self):
relpath = self.hashed_file_path("cached/data_uri_with_nested_url.css")
with storage.staticfiles_storage.open(relpath) as relfile:
content = relfile.read()
self.assertIn(b'url("data:image/svg+xml,url(%23b) url(%23c)")', content)
self.assertPostCondition()
def test_css_source_map(self):
relpath = self.hashed_file_path("cached/source_map.css")
self.assertEqual(relpath, "cached/source_map.b2fceaf426aa.css")