Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
tools: Fix out-of-bounds error for `get_handlebars_tag`.
apoorvapendsea935866601da
diff --git a/tools/lib/template_parser.py b/tools/lib/template_parser.pyindex ae1f1cd0591..2d763937179 100644--- a/tools/lib/template_parser.py+++ b/tools/lib/template_parser.py@@ -624,7 +624,7 @@ def is_django_block_tag(tag: str) -> bool:def get_handlebars_tag(text: str, i: int) -> str:end = i + 2- while end < len(text) - 1 and text[end] != "}":+ while end < len(text) - 2 and text[end] != "}":end += 1if text[end] != "}" or text[end + 1] != "}":raise TokenizationError('Tag missing "}}"', text[i : end + 2])diff --git a/tools/tests/test_template_parser.py b/tools/tests/test_template_parser.pyindex 5ec358073ac..cef4857c3cf 100644--- a/tools/tests/test_template_parser.py+++ b/tools/tests/test_template_parser.py@@ -139,6 +139,14 @@ class ParserTest(unittest.TestCase):template_format="handlebars",)+ def test_validate_incomplete_handlebars_tag_3(self) -> None:+ my_html = "{{# foo}"+ self._assert_validate_error(+ 'Tag missing "}}" at line 1 col 1:"{{# foo}"',+ text=my_html,+ template_format="handlebars",+ )+def test_validate_incomplete_django_tag_1(self) -> None:my_html = """{% foo