[Django] #29167: collectstatic breaks Bootstrap 4 styles

45 views
Skip to first unread message

Django

unread,
Feb 27, 2018, 12:17:34 PM2/27/18
to django-...@googlegroups.com
#29167: collectstatic breaks Bootstrap 4 styles
-----------------------------------------------+------------------------
Reporter: Clem Flory | Owner: nobody
Type: Bug | Status: new
Component: contrib.staticfiles | Version: 2.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------------+------------------------
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()`:
{{{#!css
.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.

--
Ticket URL: <https://code.djangoproject.com/ticket/29167>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 28, 2018, 7:40:16 AM2/28/18
to django-...@googlegroups.com
#29167: HashedFilesMixin doesn't work with data URIs that include a closing
parenthesis
-------------------------------------+------------------------------------

Reporter: Clem Flory | Owner: nobody
Type: Bug | Status: new
Component: contrib.staticfiles | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/29167#comment:1>

Django

unread,
Feb 16, 2024, 3:14:47 PM2/16/24
to django-...@googlegroups.com
#29167: HashedFilesMixin doesn't work with data URIs that include a closing
parenthesis
-------------------------------------+------------------------------------
Reporter: Clem Flory | Owner: nobody
Type: Bug | Status: new
Component: contrib.staticfiles | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Comment (by Adam Zapletal):

It looks like this was fixed in mid-2022 by commit
e6f36ea0a97af5c7d18bd155a6c4a937cf658ce6.

I tried the CSS above with `ManifestStaticFilesStorage` on Django v5.0.2,
and it works fine. `collectstatic` didnt't crash, and the CSS was
unchanged.
--
Ticket URL: <https://code.djangoproject.com/ticket/29167#comment:2>

Django

unread,
Feb 16, 2024, 3:22:42 PM2/16/24
to django-...@googlegroups.com
#29167: HashedFilesMixin doesn't work with data URIs that include a closing
parenthesis
-------------------------------------+------------------------------------
Reporter: Clem Flory | Owner: nobody
Type: Bug | Status: new
Component: contrib.staticfiles | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Changes (by Adam Zapletal):

* cc: Adam Zapletal (added)

--
Ticket URL: <https://code.djangoproject.com/ticket/29167#comment:3>

Django

unread,
Feb 17, 2024, 2:22:05 AM2/17/24
to django-...@googlegroups.com
#29167: HashedFilesMixin doesn't work with data URIs that include a closing
parenthesis
-------------------------------------+------------------------------------
Reporter: Clem Flory | Owner: nobody
Type: Bug | Status: new
Component: contrib.staticfiles | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Comment (by Mariusz Felisiak):

Adam, Can you submit PR with a regression test to prove it's fixed?
--
Ticket URL: <https://code.djangoproject.com/ticket/29167#comment:4>

Django

unread,
Feb 17, 2024, 1:40:27 PM2/17/24
to django-...@googlegroups.com
#29167: HashedFilesMixin doesn't work with data URIs that include a closing
parenthesis
-------------------------------------+-------------------------------------
Reporter: Clem Flory | Owner: Adam
| Zapletal
Type: Bug | Status: assigned
Component: contrib.staticfiles | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Adam Zapletal):

* owner: nobody => Adam Zapletal
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/29167#comment:5>

Django

unread,
Feb 17, 2024, 1:40:33 PM2/17/24
to django-...@googlegroups.com
#29167: HashedFilesMixin doesn't work with data URIs that include a closing
parenthesis
-------------------------------------+-------------------------------------
Reporter: Clem Flory | Owner: Adam
| Zapletal
Type: Bug | Status: assigned
Component: contrib.staticfiles | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Adam Zapletal):

PR is ready!
--
Ticket URL: <https://code.djangoproject.com/ticket/29167#comment:6>

Django

unread,
Feb 19, 2024, 2:21:34 PM2/19/24
to django-...@googlegroups.com
#29167: HashedFilesMixin doesn't work with data URIs that include a closing
parenthesis
-------------------------------------+-------------------------------------
Reporter: Clem Flory | Owner: Adam
| Zapletal
Type: Bug | Status: assigned
Component: contrib.staticfiles | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Adam Zapletal):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/29167#comment:7>

Django

unread,
Feb 19, 2024, 11:44:19 PM2/19/24
to django-...@googlegroups.com
#29167: HashedFilesMixin doesn't work with data URIs that include a closing
parenthesis
-------------------------------------+-------------------------------------
Reporter: Clem Flory | Owner: Adam
| Zapletal
Type: Bug | Status: closed
Component: contrib.staticfiles | Version: 2.0
Severity: Normal | Resolution:
| worksforme
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* resolution: => worksforme
* stage: Accepted => Unreviewed
* status: assigned => closed

Comment:

Closing as "worksforme" unless someone can provide a reproducible
scenario. Thanks Adam Zapletal for the investigation:
> ''I tested this all the way back to Django v2.0.2, which is the release
the bug reporter was probably using, and Python 3.8. I wasn't able to
reproduce the bug. In the process, I realized that Django has been
skipping the processing of `data:` URLs since
46c12d1293aa90209f3c640f214c4b5a3d6cb9e6. That was well before the version
specified on the ticket.''
>
> ''Other than adding named groups, I don't think the regex in question
has changed at all since it was initially added in
1d32bdd3c9586ff10d0799264105850fa7e3f512. The ticket is correct in that
the regex doesn't match to the final closing parenthesis, but it doesn't
need to because `data:` URLs are skipped.''
>
> ''I'm unsure how the bug reporter was able to get unexpected behavior. I
doubt that this PR is even needed since there's already an assert for
`data:` URLs in the tests, and I wonder if the ticket is even valid.''
--
Ticket URL: <https://code.djangoproject.com/ticket/29167#comment:8>
Reply all
Reply to author
Forward
0 new messages