mirror of
https://github.com/django/django.git
synced 2025-08-10 11:59:13 +00:00
Fixed #35897 -- Removed unnecessary escaping in template's get_exception_info().
This commit is contained in:
parent
1636912bf1
commit
1722f2db58
@ -57,7 +57,7 @@ from enum import Enum
|
|||||||
|
|
||||||
from django.template.context import BaseContext
|
from django.template.context import BaseContext
|
||||||
from django.utils.formats import localize
|
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.regex_helper import _lazy_re_compile
|
||||||
from django.utils.safestring import SafeData, SafeString, mark_safe
|
from django.utils.safestring import SafeData, SafeString, mark_safe
|
||||||
from django.utils.text import get_text_list, smart_split, unescape_string_literal
|
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)):
|
for num, next in enumerate(linebreak_iter(self.source)):
|
||||||
if start >= upto and end <= next:
|
if start >= upto and end <= next:
|
||||||
line = num
|
line = num
|
||||||
before = escape(self.source[upto:start])
|
before = self.source[upto:start]
|
||||||
during = escape(self.source[start:end])
|
during = self.source[start:end]
|
||||||
after = escape(self.source[end:next])
|
after = self.source[end:next]
|
||||||
source_lines.append((num, escape(self.source[upto:next])))
|
source_lines.append((num, self.source[upto:next]))
|
||||||
upto = next
|
upto = next
|
||||||
total = len(source_lines)
|
total = len(source_lines)
|
||||||
|
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
{% extends "test_extends_block_error_parent.html" %}
|
{% 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 %}
|
||||||
|
@ -5,7 +5,6 @@ from django.template.base import UNKNOWN_SOURCE
|
|||||||
from django.test import SimpleTestCase, override_settings
|
from django.test import SimpleTestCase, override_settings
|
||||||
from django.urls import NoReverseMatch
|
from django.urls import NoReverseMatch
|
||||||
from django.utils import translation
|
from django.utils import translation
|
||||||
from django.utils.html import escape
|
|
||||||
|
|
||||||
|
|
||||||
class TemplateTestMixin:
|
class TemplateTestMixin:
|
||||||
@ -158,9 +157,31 @@ class TemplateTestMixin:
|
|||||||
template.render(context)
|
template.render(context)
|
||||||
if self.debug_engine:
|
if self.debug_engine:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
cm.exception.template_debug["during"],
|
cm.exception.template_debug["before"],
|
||||||
escape('{% include "missing.html" %}'),
|
'{% 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):
|
def test_super_errors(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user