Protect against nameless HTML tags in tools/lib/template_parser.py.

Fixed IndexError when there is only zero or more whitespace characters
between < and >. (str.split() will return an empty list in this case, which
means there is no index 0.)
This commit is contained in:
Gordon P. Hemsley
2016-08-30 18:54:41 -04:00
parent c9d1a4247f
commit 2e865f03bf
2 changed files with 14 additions and 1 deletions

View File

@@ -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('/>'):