[Django] #33237: ManifestStaticFilesStorage doesn't update JavaScript source map references in multiline files

16 views
Skip to first unread message

Django

unread,
Oct 28, 2021, 4:47:21 PM10/28/21
to django-...@googlegroups.com
#33237: ManifestStaticFilesStorage doesn't update JavaScript source map references
in multiline files
-----------------------------------------------+------------------------
Reporter: Joseph Abrahams | Owner: nobody
Type: Bug | Status: new
Component: contrib.staticfiles | Version: 4.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 |
-----------------------------------------------+------------------------
Current implementation of `HashedFilesMixin` relies on regex multiline
mode to parse out the sourceMappingURL comment. As is, the filename is
only correctly replaced when the comment is the first and only line in the
JS file (exception to final single new line at EOF).

Steps to reproduce:
- Include static multi-line javascript file that contains a valid
sourceMappingURL comment in a project with `STATICFILES_STORAGE =
'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'`
- Run `python manage.py collectstatic`
- Open the new hashed javascript file and observe the unmodified
sourceMappingURL comment

See updated, failing test case: [https://joseph.is/3CrvpSW].

More than happy to work on a patch provided some guidance on expected
functionality.

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

Django

unread,
Oct 29, 2021, 12:21:54 AM10/29/21
to django-...@googlegroups.com
#33237: ManifestStaticFilesStorage doesn't update JavaScript source map references
in multiline files
-------------------------------------+------------------------------------

Reporter: Joseph Abrahams | Owner: nobody
Type: Bug | Status: new
Component: contrib.staticfiles | Version: 4.0
Severity: Release blocker | 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 Mariusz Felisiak):

* cc: Adam Johnson (added)
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted


Comment:

Thanks for the report, it's a bug in a new feature introduced in
e32722d1606794f0a85d74811e53a0336a1ce305 (see #32383).

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

Django

unread,
Nov 4, 2021, 5:41:25 AM11/4/21
to django-...@googlegroups.com
#33237: ManifestStaticFilesStorage doesn't update JavaScript source map references
in multiline files
-------------------------------------+-------------------------------------
Reporter: Joseph Abrahams | Owner: Carlton
| Gibson
Type: Bug | Status: assigned
Component: contrib.staticfiles | Version: 4.0

Severity: Release blocker | 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 Carlton Gibson):

* owner: nobody => Carlton Gibson
* status: new => assigned
* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/15056 PR] switching the regex to
multiline mode.

Joseph, if you're able to have a look, that would be great.

--
Ticket URL: <https://code.djangoproject.com/ticket/33237#comment:2>

Django

unread,
Nov 4, 2021, 6:10:58 AM11/4/21
to django-...@googlegroups.com
#33237: ManifestStaticFilesStorage doesn't update JavaScript source map references
in multiline files
-------------------------------------+-------------------------------------
Reporter: Joseph Abrahams | Owner: Carlton
| Gibson
Type: Bug | Status: assigned
Component: contrib.staticfiles | Version: 4.0

Severity: Release blocker | 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 Carlton Gibson):

* cc: gilmrjc (added)


Comment:

Looks like the regression was introduced in
781b44240a06f0c868254f40f36ce46c927f56d1 as part of #32319.
(The multiline flag was removed switching to named groups.)

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

Django

unread,
Nov 4, 2021, 8:26:09 AM11/4/21
to django-...@googlegroups.com
#33237: ManifestStaticFilesStorage doesn't update JavaScript source map references
in multiline files
-------------------------------------+-------------------------------------
Reporter: Joseph Abrahams | Owner: Carlton
| Gibson
Type: Bug | Status: assigned
Component: contrib.staticfiles | Version: 4.0
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/33237#comment:4>

Django

unread,
Nov 4, 2021, 4:39:50 PM11/4/21
to django-...@googlegroups.com
#33237: ManifestStaticFilesStorage doesn't update JavaScript source map references
in multiline files
-------------------------------------+-------------------------------------
Reporter: Joseph Abrahams | Owner: Carlton
| Gibson
Type: Bug | Status: closed
Component: contrib.staticfiles | Version: 4.0
Severity: Release blocker | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"4816dc942860caf076c7c85ea9dbfa8bfab212ff" 4816dc9]:
{{{
#!CommitTicketReference repository=""
revision="4816dc942860caf076c7c85ea9dbfa8bfab212ff"
Fixed #33237 -- Fixed detecting source maps in ManifestStaticFilesStorage
for multiline files.

Switched regex to multiline mode in order to match per-line, rather
than against the whole file.

Thanks to Joseph Abrahams for the report.

Regression in 781b44240a06f0c868254f40f36ce46c927f56d1.
}}}

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

Django

unread,
Nov 4, 2021, 4:42:12 PM11/4/21
to django-...@googlegroups.com
#33237: ManifestStaticFilesStorage doesn't update JavaScript source map references
in multiline files
-------------------------------------+-------------------------------------
Reporter: Joseph Abrahams | Owner: Carlton
| Gibson
Type: Bug | Status: closed
Component: contrib.staticfiles | Version: 4.0

Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"499384b6d1a0082d538470d57ade37591e9251d6" 499384b]:
{{{
#!CommitTicketReference repository=""
revision="499384b6d1a0082d538470d57ade37591e9251d6"
[4.0.x] Fixed #33237 -- Fixed detecting source maps in
ManifestStaticFilesStorage for multiline files.

Switched regex to multiline mode in order to match per-line, rather
than against the whole file.

Thanks to Joseph Abrahams for the report.

Regression in 781b44240a06f0c868254f40f36ce46c927f56d1.

Backport of 4816dc942860caf076c7c85ea9dbfa8bfab212ff from main
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33237#comment:6>

Reply all
Reply to author
Forward
0 new messages