﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
37530	The multiline `endcomment` closes the block early, leaving the final, single-line `endcomment` outside it.	Cleisson	Cleisson	"The [https://docs.djangoproject.com/en/dev/releases/6.2/#multiline-template-tag-parsing Django 6.2 release notes] say that setting `allow_multiline_tags=False` restores the previous template parsing behavior. However, the template below compiles on Django 6.1 but fails on 6.2 even with this setting.

To reproduce on the Django 6.2 development version:

{{{
#!python
from django.template import Context, Engine

source = ""{% comment %}x{%\nendcomment %}y{% endcomment %}z""
print(Engine(allow_multiline_tags=False).from_string(source).render(Context()))
}}}

Expected output: `z`. The first `endcomment` has its `{%` and `%}` on separate lines, so it should remain comment text. The final, single-line `endcomment` should close the block. On Django 6.1.3, the same template prints `z` using `Engine()` without the new option.

On `main` at `c67d872765e05ebd009fadf7de8d834b01bae9e4` (6.2 alpha 0), it raises:

{{{
TemplateSyntaxError: Invalid block tag on line 2: 'endcomment'. Did you forget to register or load this tag?
}}}

The multiline `endcomment` closes the block early, leaving the final, single-line `endcomment` outside it. Both versions were tested with Python 3.14.6.

`Lexer._tag_re_split()` uses separate patterns to match closing tags inside `comment` and `verbatim` blocks. These patterns still match across newlines when `allow_multiline_tags=False`. This also affects named and unnamed `verbatim` blocks: they end early instead of rendering the multiline lookalike as literal text.

With `allow_multiline_tags=True`, a multiline closing tag on its own ends each block as expected. #37518 concerns a missing space between `endverbatim` and the block name in the default mode.

AI disclosure: OpenAI GPT-6.2 (Astra and Sol, via OpenCode) was used to investigate and reproduce the bug."	Bug	assigned	Template system	dev	Normal				Unreviewed	0	0	0	0	0	0
