django-static icon indicating copy to clipboard operation
django-static copied to clipboard

CSS url() with embed data surrounded by quotation marks is imporperly rendered

Open lysyloren opened this issue 11 years ago • 3 comments

When someone embed data in CSS using url() and surrounds it with quotation marks " or ', django_static wrongly prepend current file path data. Example:

background-image: url("data:image/png;base64,...")

is rendered to:

background-image:url("/core/css/data:image/png;base64,...")

Proposed fix is to improve regexp in templatetags/django_static.py to this one:

REFERRED_CSS_URLS_REGEX = re.compile('''url\(((?!["']+data:)[^\)]+)\)''')

lysyloren avatar Oct 08 '14 17:10 lysyloren

Oh, regexp fix should look like (? instead of + on qutoation marks match):

REFERRED_CSS_URLS_REGEX = re.compile('''url\(((?!["']?data:)[^\)]+)\)''')

lysyloren avatar Oct 09 '14 12:10 lysyloren

If you make a pull request that fixes it, I'll merge it.

peterbe avatar Oct 10 '14 22:10 peterbe

Pull request #36 made.

lysyloren avatar Oct 27 '14 09:10 lysyloren