Opened 8 years ago

Closed 8 years ago

#28271 closed Bug (fixed)

Debug view's AJAX response doesn't have the proper charset

Reported by: Sergey Tereschenko Owned by: Tim Graham <timograham@…>
Component: Error reporting Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

In django/views/debug.py
technical_500_response uses content-type text-plain for ajax requests and text-html for normal requests.

TECHNICAL_500_TEMPLATE includes meta tag

<meta http-equiv="content-type" content="text/html; charset=utf-8">

And so it supports unicode.

Traceback for AJAX request must use

HttpResponse(text, status=status_code, content_type='text/plain; charset=utf-8')

to support unicode. But now it's just 'text-plain'

Attachments (1)

0001-technical_500_response-utf-8-encoding-for-AJAX-reque.patch (1.0 KB ) - added by Sergey Tereschenko 8 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 by Tim Graham, 8 years ago

Does the browser misinterpret data without the charset? Maybe you can also add a test in tests/view_tests/tests/test_debug.py and send a pull request?

comment:2 by Sergey Tereschenko, 8 years ago

Yeah, without charset browser (Chromium at least) displays broken charset.

I can create pull request, and probably, i can add test.

But what should i verify? something like

self.assert(response.content_type, 'text/plain; charset=utf-8')

? Don't know if that will be useful as test case.

comment:3 by Tim Graham, 8 years ago

Needs tests: set
Summary: AJAX traceback in DEBUG mode doesn't support unicodeDebug view's AJAX response doesn't have the proper charset
Triage Stage: UnreviewedAccepted

Yes, I don't think more than a 1 line assertion is needed for the test.

comment:4 by Sergey Tereschenko, 8 years ago

tests and pull request is ready

https://github.com/django/django/pull/8597

comment:5 by Tim Graham <timograham@…>, 8 years ago

Owner: set to Tim Graham <timograham@…>
Resolution: fixed
Status: newclosed

In ff099f9:

Fixed #28271 -- Added charset to technical_500_response() AJAX response.

Note: See TracTickets for help on using tickets.
Back to Top