0
0
mirror of https://github.com/django/django.git synced 2024-11-21 19:09:18 +01:00

Fixed #35897 -- Removed unnecessary escaping in template's get_exception_info().

This commit is contained in:
Klaas van Schelven 2024-11-08 09:55:28 +01:00 committed by Sarah Boyce
parent 042b381e2e
commit 10af0b6a57
3 changed files with 30 additions and 9 deletions

View File

@ -57,7 +57,7 @@ from enum import Enum
from django.template.context import BaseContext
from django.utils.formats import localize
from django.utils.html import conditional_escape, escape
from django.utils.html import conditional_escape
from django.utils.regex_helper import _lazy_re_compile
from django.utils.safestring import SafeData, SafeString, mark_safe
from django.utils.text import get_text_list, smart_split, unescape_string_literal
@ -247,10 +247,10 @@ class Template:
for num, next in enumerate(linebreak_iter(self.source)):
if start >= upto and end <= next:
line = num
before = escape(self.source[upto:start])
during = escape(self.source[start:end])
after = escape(self.source[end:next])
source_lines.append((num, escape(self.source[upto:next])))
before = self.source[upto:start]
during = self.source[start:end]
after = self.source[end:next]
source_lines.append((num, self.source[upto:next]))
upto = next
total = len(source_lines)

View File

@ -1,2 +1,2 @@
{% extends "test_extends_block_error_parent.html" %}
{% block content %}{% include "missing.html" %}{% endblock %}
{% block content %}{% include "index.html" %}{% include "missing.html" %}{% include "index.html" %}{% endblock %}

View File

@ -5,7 +5,6 @@ from django.template.base import UNKNOWN_SOURCE
from django.test import SimpleTestCase, override_settings
from django.urls import NoReverseMatch
from django.utils import translation
from django.utils.html import escape
class TemplateTestMixin:
@ -158,9 +157,31 @@ class TemplateTestMixin:
template.render(context)
if self.debug_engine:
self.assertEqual(
cm.exception.template_debug["during"],
escape('{% include "missing.html" %}'),
cm.exception.template_debug["before"],
'{% block content %}{% include "index.html" %}',
)
self.assertEqual(
cm.exception.template_debug["during"],
'{% include "missing.html" %}',
)
self.assertEqual(
cm.exception.template_debug["after"],
'{% include "index.html" %}{% endblock %}\n',
)
self.assertEqual(
cm.exception.template_debug["source_lines"][0],
(1, '{% extends "test_extends_block_error_parent.html" %}\n'),
)
self.assertEqual(
cm.exception.template_debug["source_lines"][1],
(
2,
'{% block content %}{% include "index.html" %}'
'{% include "missing.html" %}'
'{% include "index.html" %}{% endblock %}\n',
),
)
self.assertEqual(cm.exception.template_debug["source_lines"][2], (3, ""))
def test_super_errors(self):
"""