mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Refs #7697 -- Removed unnecessary force_escape of technical 500 debug view "unicode hint".
The test passes before and after the removal. unicode_hint will never be SafeText, so normal autoescaping is sufficient.
This commit is contained in:
parent
74b7a20fe6
commit
293608a2e0
@ -162,7 +162,7 @@
|
||||
{% if unicode_hint %}
|
||||
<div id="unicode-hint">
|
||||
<h2>Unicode error hint</h2>
|
||||
<p>The string that could not be encoded/decoded was: <strong>{{ unicode_hint|force_escape }}</strong></p>
|
||||
<p>The string that could not be encoded/decoded was: <strong>{{ unicode_hint }}</strong></p>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if template_does_not_exist %}
|
||||
|
@ -18,6 +18,7 @@ from django.test.utils import LoggingCaptureMixin, patch_logger
|
||||
from django.urls import reverse
|
||||
from django.utils.encoding import force_bytes
|
||||
from django.utils.functional import SimpleLazyObject
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.views.debug import (
|
||||
CLEANSED_SUBSTITUTE, CallableSettingWrapper, ExceptionReporter,
|
||||
cleanse_setting, technical_500_response,
|
||||
@ -447,16 +448,19 @@ class ExceptionReporterTests(SimpleTestCase):
|
||||
self.assertIn('<trimmed %d bytes string>' % (large + repr_of_str_adds,), html)
|
||||
|
||||
def test_encoding_error(self):
|
||||
"""A UnicodeError displays a portion of the problematic string."""
|
||||
"""
|
||||
A UnicodeError displays a portion of the problematic string. HTML in
|
||||
safe strings is escaped.
|
||||
"""
|
||||
try:
|
||||
'abcdefghijklmnὀpqrstuwxyz'.encode('ascii')
|
||||
mark_safe('abcdefghijkl<p>mnὀp</p>qrstuwxyz').encode('ascii')
|
||||
except Exception:
|
||||
exc_type, exc_value, tb = sys.exc_info()
|
||||
reporter = ExceptionReporter(None, exc_type, exc_value, tb)
|
||||
html = reporter.get_traceback_html()
|
||||
self.assertIn('<h2>Unicode error hint</h2>', html)
|
||||
self.assertIn('The string that could not be encoded/decoded was: ', html)
|
||||
self.assertIn('<strong>jklmnὀpqrst</strong>', html)
|
||||
self.assertIn('<strong><p>mnὀp</p></strong>', html)
|
||||
|
||||
def test_unfrozen_importlib(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user