mirror of https://github.com/zulip/zulip.git
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:
parent
c9d1a4247f
commit
2e865f03bf
|
@ -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('/>'):
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue