8000 Fixed #36348 -- Fixed handling multiple nested url()s in ManifestStat… · django/django@43c8470 · GitHub
[go: up one dir, main page]

Skip to content

Commit 43c8470

Browse files
sciyoshijrsenthil-kumar2312
authored andcommitted
Fixed #36348 -- Fixed handling multiple nested url()s in ManifestStaticFilesStorage.
Signed-off-by: Samuel Cormier-Iijima <samuel@cormier-iijima.com>
1 parent 8f1dee7 commit 43c8470

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

django/contrib/staticfiles/storage.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ class HashedFilesMixin:
8080
(
8181
"*.css",
8282
(
83-
r"""(?P<matched>url\(['"]{0,1}\s*(?P<url>.*?)["']{0,1}\))""",
83+
r"""(?P<matched>url\((?P<quote>['"]{0,1})"""
84+
r"""\s*(?P<url>.*?)(?P=quote)\))""",
8485
(
8586
r"""(?P<matched>@import\s*["']\s*(?P<url>.*?)["'])""",
8687
"""@import url("%(url)s")""",
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#example {
2+
background-image: url("data:image/svg+xml,url(%23b) url(%23c)");
3+
}

tests/staticfiles_tests/test_storage.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,13 @@ def test_css_import_case_insensitive(self):
235235
self.assertIn(b"other.d41d8cd98f00.css", content)
236236
self.assertPostCondition()
237237

238+
def test_css_data_uri_with_nested_url(self):
239+
relpath = self.hashed_file_path("cached/data_uri_with_nested_url.css")
240+
with storage.staticfiles_storage.open(relpath) as relfile:
241+
content = relfile.read()
242+
self.assertIn(b'url("data:image/svg+xml,url(%23b) url(%23c)")', content)
243+
self.assertPostCondition()
244+
238245
def test_css_source_map(self):
239246
relpath = self.hashed_file_path("cached/source_map.css")
240247
self.assertEqual(relpath, "cached/source_map.b2fceaf426aa.css")

0 commit comments

Comments
 (0)
0