peterbe / django-static

Template tags for better serving static files from templates in Django
BSD 2-Clause "Simplified" License
193 stars 28 forks source link

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

Open lysyloren opened 9 years ago

lysyloren commented 9 years ago

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 commented 9 years ago

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

REFERRED_CSS_URLS_REGEX = re.compile('''url\(((?!["']?data:)[^\)]+)\)''')
peterbe commented 9 years ago

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

lysyloren commented 9 years ago

Pull request #36 made.