diff --git a/tools/lib/template_parser.py b/tools/lib/template_parser.py index f323f4947f..a39dbcc58f 100644 --- a/tools/lib/template_parser.py +++ b/tools/lib/template_parser.py @@ -69,7 +69,13 @@ def tokenize(text): while state.i < len(text): if looking_at_html_start(): s = get_html_tag(text, state.i) - tag = s[1:-1].split()[0] + tag_parts = s[1:-1].split() + + if not tag_parts: + raise TemplateParserException("Tag name missing") + + tag = tag_parts[0] + if is_special_html_tag(s, tag): kind = 'html_special' elif s.endswith('/>'): diff --git a/tools/tests/test_template_parser.py b/tools/tests/test_template_parser.py index d63b8caf1e..af4d157a6f 100644 --- a/tools/tests/test_template_parser.py +++ b/tools/tests/test_template_parser.py @@ -127,6 +127,13 @@ class ParserTest(unittest.TestCase): ''' self._assert_validate_error('Tag missing >', text=my_html) + def test_validate_empty_html_tag(self): + # type: () -> None + my_html = ''' + < > + ''' + self._assert_validate_error('Tag name missing', text=my_html) + def test_code_blocks(self): # type: () -> None