From f8e1ebd4fb67d4180c17184874a5bd0240ba253e Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 20 Oct 2018 19:37:01 +1000 Subject: [PATCH] prevent infinite loop with invalid template --- anki/template/template.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/anki/template/template.py b/anki/template/template.py index 92f187bfe..1262d3bf8 100644 --- a/anki/template/template.py +++ b/anki/template/template.py @@ -108,7 +108,13 @@ class Template: def render_tags(self, template, context): """Renders all the tags in a template for a context.""" + repCount = 0 while 1: + if repCount > 100: + print("too many replacements") + break + repCount += 1 + match = self.tag_re.search(template) if match is None: break