From b1127d6d38230875150f17d7fdcff850f7a8ffa4 Mon Sep 17 00:00:00 2001 From: Aaron Taylor Date: Tue, 1 Nov 2022 15:15:08 -0400 Subject: [PATCH] fix #1155: Catastrophic backtracking issue in template parser. Related to #1194 This backports the patch from 332215b2b1b3de5a321ba9f3497777fc93662893 to the 0.12 release branch. This fix can be validated using the following repl commands: >>> import bottle >>> bottle.template("""Sem imagem""") --- bottle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bottle.py b/bottle.py index 8dee39d0..c7bc18c9 100644 --- a/bottle.py +++ b/bottle.py @@ -3486,7 +3486,7 @@ class StplParser(object): # Match the start tokens of code areas in a template _re_split = '(?m)^[ \t]*(\\\\?)((%(line_start)s)|(%(block_start)s))(%%?)' # Match inline statements (may contain python strings) - _re_inl = '(?m)%%(inline_start)s((?:%s|[^\'"\n]*?)+)%%(inline_end)s' % _re_inl + _re_inl = '(?m)%%(inline_start)s((?:%s|[^\'"\n])*?)%%(inline_end)s' % _re_inl _re_tok = '(?m)' + _re_tok default_syntax = '<% %> % {{ }}'