Added lookaheads to regex pattern in Template tokenizing to avoid backtracing as described in ticket #65675.

This commit is contained in:
haileyajohnson 2025-04-08 08:52:08 -07:00
parent 71a19a0e47
commit 5d88603feb

View file

@ -86,7 +86,7 @@ UNKNOWN_SOURCE = "<unknown source>"
# Match BLOCK_TAG_*, VARIABLE_TAG_*, and COMMENT_TAG_* tags and capture the
# entire tag, including start/end delimiters. Using re.compile() is faster
# than instantiating SimpleLazyObject with _lazy_re_compile().
tag_re = re.compile(r"({%.*?%}|{{.*?}}|{#.*?#})")
tag_re = re.compile(r"({%(?=.*%}).*?%}|{{(?=.*}}).*?}}|{#(?=.*#}).*?#})")
logger = logging.getLogger("django.template")