Opened 6 years ago

Last modified 6 years ago

#29167 new Bug

HashedFilesMixin doesn't work with data URIs that include a closing parenthesis

Reported by: Clem Flory Owned by: nobody
Component: contrib.staticfiles Version: 2.0
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

My team recently started using Bootstrap 4, and some of their styles get broken by the regex patterns in HashedFilesMixin (https://github.com/django/django/blob/2.0.2/django/contrib/staticfiles/storage.py#L52-L57). This is loosely related to #21080.

For example, this is one of the rules in the generated Bootstrap 4 CSS, and the current regex incorrectly mistakes the closing parentheses in rgba(0, 0, 0, 0.5) as the end of url():

.navbar-light .navbar-toggler-icon {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 30 30' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(0, 0, 0, 0.5)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 7h22M4 15h22M4 23h22'/%3E%3C/svg%3E");
}

Not an ideal solution, but we were able to work around this issue by Base64 encoding these data URIs.

Change History (1)

comment:1 Changed 6 years ago by Tim Graham

Summary: collectstatic breaks Bootstrap 4 stylesHashedFilesMixin doesn't work with data URIs that include a closing parenthesis
Triage Stage: UnreviewedAccepted
Note: See TracTickets for help on using tickets.
Back to Top