[Django] #29511: Set the chartset on JavaScript catalog in Django Views i18n

6 views
Skip to first unread message

Django

unread,
Jun 21, 2018, 7:44:05 AM6/21/18
to django-...@googlegroups.com
#29511: Set the chartset on JavaScript catalog in Django Views i18n
-------------------------------------------+------------------------
Reporter: Roland van Laar | Owner: nobody
Type: Bug | Status: new
Component: Generic views | Version: 1.11
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 |
-------------------------------------------+------------------------
What I want: set the charset on responses with javascript files.

The supposed way of doing that is setting the `DEFAULT_CHARSET` in
settings.py.
However, this setting isn't used when the `content_type` is specified when
calling `HttpResponse`.

It seems to me that this is a bug. Why accept `charset` as an option when
it only does something
when `content_type` is set.

`django.views.i18n.JavascriptCatalog` sets this `text/javascript` as the
content_type.
Whereas it should be: `text/javascript; charset=utf-8`.

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

Django

unread,
Jun 21, 2018, 9:32:50 AM6/21/18
to django-...@googlegroups.com
#29511: Set the charset on the JavaScriptCatalog response
-------------------------------------+-------------------------------------

Reporter: Roland van Laar | Owner: nobody
Type: Bug | Status: new
Component: | Version: 1.11
Internationalization |
Severity: Normal | Resolution:

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

* component: Generic views => Internationalization


Comment:

Are you experiencing a problem due to the lack of `charset=utf-8.`?

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

Django

unread,
Jun 21, 2018, 9:45:11 AM6/21/18
to django-...@googlegroups.com
#29511: Set the charset on the JavaScriptCatalog response
-------------------------------------+-------------------------------------
Reporter: Roland van Laar | Owner: nobody
Type: Bug | Status: new
Component: | Version: 1.11
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Roland van Laar):

I am not experiencing problems directly. However it was 'strongly advised'
after a security audit of our application.

I was expecting it to be configurable, or to be able to inject. The way
the `HttpResponse` works is by not setting the charset when content_type
is specified.
That seems like a bug as well.

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

Django

unread,
Jun 21, 2018, 10:06:28 AM6/21/18
to django-...@googlegroups.com
#29511: Set the charset on the JavaScriptCatalog response
-------------------------------------+-------------------------------------
Reporter: Roland van Laar | Owner: nobody
Type: Bug | Status: new
Component: | Version: 1.11
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz):

I think adding the charset for `JavaScriptCatalog` makes sense.

`HttpResponse` consider that if the content_type is already set, it's the
responsability of the setter to set the charset if needed. I wouldn't
change that.

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

Django

unread,
Jun 21, 2018, 11:14:25 AM6/21/18
to django-...@googlegroups.com
#29511: Set the charset on the JavaScriptCatalog response
-------------------------------------+-------------------------------------
Reporter: Roland van Laar | Owner: nobody
Type: Bug | Status: new
Component: | Version: 1.11
Internationalization |
Severity: Normal | Resolution:
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 Tim Graham):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/10075 PR]

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

Django

unread,
Jun 21, 2018, 1:31:31 PM6/21/18
to django-...@googlegroups.com
#29511: Set the charset on the JavaScriptCatalog response
--------------------------------------+------------------------------------

Reporter: Roland van Laar | Owner: nobody
Type: Bug | Status: new
Component: Internationalization | Version: 1.11
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 Tim Graham):

* stage: Unreviewed => Accepted


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

Django

unread,
Jun 22, 2018, 2:40:43 AM6/22/18
to django-...@googlegroups.com
#29511: Set the charset on the JavaScriptCatalog response
--------------------------------------+------------------------------------
Reporter: Roland van Laar | Owner: nobody
Type: Bug | Status: new
Component: Internationalization | Version: 1.11
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
--------------------------------------+------------------------------------

Comment (by Roland van Laar):

Thank you Tim, for picking this up so quickly.

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

Django

unread,
Jun 22, 2018, 2:43:53 AM6/22/18
to django-...@googlegroups.com
#29511: Set the charset on the JavaScriptCatalog response
-------------------------------------+-------------------------------------

Reporter: Roland van Laar | Owner: nobody
Type: Bug | Status: new
Component: | Version: 1.11
Internationalization |
Severity: Normal | 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 Claude Paroz):

* stage: Accepted => Ready for checkin


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

Django

unread,
Jun 22, 2018, 3:15:59 AM6/22/18
to django-...@googlegroups.com
#29511: Set the charset on the JavaScriptCatalog response
-------------------------------------+-------------------------------------
Reporter: Roland van Laar | Owner: nobody
Type: Bug | Status: closed
Component: | Version: 1.11
Internationalization |
Severity: Normal | 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 Carlton Gibson <carlton.gibson@…>):

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


Comment:

In [changeset:"7cdeb23ae7ef2d125276840ff298dbb9683959f2" 7cdeb23]:
{{{
#!CommitTicketReference repository=""
revision="7cdeb23ae7ef2d125276840ff298dbb9683959f2"
Fixed #29511 -- Added charset to JavaScriptCatalog's Content-Type header.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29511#comment:8>

Django

unread,
Jun 22, 2018, 3:33:15 AM6/22/18
to django-...@googlegroups.com
#29511: Set the charset on the JavaScriptCatalog response
-------------------------------------+-------------------------------------
Reporter: Roland van Laar | Owner: nobody
Type: Bug | Status: closed
Component: | Version: 1.11
Internationalization |
Severity: Normal | 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 Carlton Gibson <carlton.gibson@…>):

In [changeset:"714612a638ff02f02406553a583b2f8a1a424885" 714612a6]:
{{{
#!CommitTicketReference repository=""
revision="714612a638ff02f02406553a583b2f8a1a424885"
[2.1.x] Fixed #29511 -- Added charset to JavaScriptCatalog's Content-Type
header.

Backport of 7cdeb23ae7ef2d125276840ff298dbb9683959f2 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29511#comment:9>

Django

unread,
Jun 22, 2018, 3:33:35 AM6/22/18
to django-...@googlegroups.com
#29511: Set the charset on the JavaScriptCatalog response
-------------------------------------+-------------------------------------
Reporter: Roland van Laar | Owner: nobody
Type: Bug | Status: closed
Component: | Version: 1.11
Internationalization |
Severity: Normal | 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 Carlton Gibson <carlton.gibson@…>):

In [changeset:"8e082a6e0b63a1cfdb0bc7b2835c6447123aa239" 8e082a6]:
{{{
#!CommitTicketReference repository=""
revision="8e082a6e0b63a1cfdb0bc7b2835c6447123aa239"
[2.0.x] Fixed #29511 -- Added charset to JavaScriptCatalog's Content-Type
header.

Backport of 7cdeb23ae7ef2d125276840ff298dbb9683959f2 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29511#comment:10>

Django

unread,
Jun 22, 2018, 6:39:21 AM6/22/18
to django-...@googlegroups.com
#29511: Set the charset on the JavaScriptCatalog response
-------------------------------------+-------------------------------------
Reporter: Roland van Laar | Owner: nobody
Type: Bug | Status: closed
Component: | Version: 1.11
Internationalization |
Severity: Normal | 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 Tim Graham):

How doe the fix qualify for a backport? If it does, it should have a 2.0.x
release note.

--
Ticket URL: <https://code.djangoproject.com/ticket/29511#comment:11>

Django

unread,
Jun 25, 2018, 9:44:21 AM6/25/18
to django-...@googlegroups.com
#29511: Set the charset on the JavaScriptCatalog response
-------------------------------------+-------------------------------------
Reporter: Roland van Laar | Owner: nobody
Type: Bug | Status: closed
Component: | Version: 1.11
Internationalization |
Severity: Normal | 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 Tim Graham <timograham@…>):

In [changeset:"4b3b9fab080f517b7dc41fb933f6eae3e24081ce" 4b3b9fab]:
{{{
#!CommitTicketReference repository=""
revision="4b3b9fab080f517b7dc41fb933f6eae3e24081ce"
[2.0.x] Reverted "Fixed #29511 -- Added charset to JavaScriptCatalog's
Content-Type header."

This reverts commit 8e082a6e0b63a1cfdb0bc7b2835c6447123aa239 as it
doesn't qualify for a backport.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29511#comment:12>

Reply all
Reply to author
Forward
0 new messages