Fixed #32990 -- Simplified and optimized tag regex.

Thanks Chris Jerdonek for the review.
This commit is contained in:
Greg Twohig 2021-08-06 13:45:17 +03:00 committed by Mariusz Felisiak
parent c99aaf14ee
commit fc2bd40fc7
2 changed files with 5 additions and 6 deletions

View File

@ -356,6 +356,7 @@ answer newbie questions, and generally made Django that much better:
Graham Carlyle <graham.carlyle@maplecroft.net>
Grant Jenks <contact@grantjenks.com>
Greg Chapple <gregchapple1@gmail.com>
Greg Twohig
Gregor Allensworth <greg.allensworth@gmail.com>
Gregor Müllegger <gregor@muellegger.de>
Grigory Fateyev <greg@dial.com.ru>

View File

@ -85,12 +85,10 @@ SINGLE_BRACE_END = '}'
# (e.g. strings)
UNKNOWN_SOURCE = '<unknown source>'
# match a variable or block tag and capture the entire tag, including start/end
# delimiters
tag_re = (_lazy_re_compile('(%s.*?%s|%s.*?%s|%s.*?%s)' %
(re.escape(BLOCK_TAG_START), re.escape(BLOCK_TAG_END),
re.escape(VARIABLE_TAG_START), re.escape(VARIABLE_TAG_END),
re.escape(COMMENT_TAG_START), re.escape(COMMENT_TAG_END))))
# 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'({%.*?%}|{{.*?}}|{#.*?#})')
logger = logging.getLogger('django.template')