diff --git a/django/views/templates/technical_500.html b/django/views/templates/technical_500.html index cb3254b5c94..01534f80d94 100644 --- a/django/views/templates/technical_500.html +++ b/django/views/templates/technical_500.html @@ -162,7 +162,7 @@ {% if unicode_hint %}

Unicode error hint

-

The string that could not be encoded/decoded was: {{ unicode_hint|force_escape }}

+

The string that could not be encoded/decoded was: {{ unicode_hint }}

{% endif %} {% if template_does_not_exist %} diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py index aa0a025eedb..767fdfdbc9b 100644 --- a/tests/view_tests/tests/test_debug.py +++ b/tests/view_tests/tests/test_debug.py @@ -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

mnὀ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('

Unicode error hint

', html) self.assertIn('The string that could not be encoded/decoded was: ', html) - self.assertIn('jklmnὀpqrst', html) + self.assertIn('<p>mnὀp</p>', html) def test_unfrozen_importlib(self): """