mirror of https://github.com/zulip/zulip.git
Clean up how missing end tags are handled in template parsing.
The null token was an artificial placeholder that wasn't making clear what the problem was. Throwing an exception is bolder.
This commit is contained in:
parent
2e865f03bf
commit
3ffc6b5a35
|
@ -211,16 +211,8 @@ def validate(fn=None, text=None, check_indent=True):
|
||||||
elif kind == 'django_end':
|
elif kind == 'django_end':
|
||||||
state.matcher(token)
|
state.matcher(token)
|
||||||
|
|
||||||
null_token = Token(
|
|
||||||
kind=None,
|
|
||||||
s='(NO TAG)',
|
|
||||||
tag='NO TAG',
|
|
||||||
line=0,
|
|
||||||
col=0,
|
|
||||||
)
|
|
||||||
|
|
||||||
if state.depth != 0:
|
if state.depth != 0:
|
||||||
state.matcher(null_token)
|
raise TemplateParserException('Missing end tag')
|
||||||
|
|
||||||
def is_special_html_tag(s, tag):
|
def is_special_html_tag(s, tag):
|
||||||
# type: (str, str) -> bool
|
# type: (str, str) -> bool
|
||||||
|
|
|
@ -85,6 +85,13 @@ class ParserTest(unittest.TestCase):
|
||||||
'''
|
'''
|
||||||
self._assert_validate_error('Bad indentation.', text=my_html, check_indent=True)
|
self._assert_validate_error('Bad indentation.', text=my_html, check_indent=True)
|
||||||
|
|
||||||
|
def test_validate_state_depth(self):
|
||||||
|
# type: () -> None
|
||||||
|
my_html = '''
|
||||||
|
<b>
|
||||||
|
'''
|
||||||
|
self._assert_validate_error('Missing end tag', text=my_html)
|
||||||
|
|
||||||
def test_validate_incomplete_handlebars_tag_1(self):
|
def test_validate_incomplete_handlebars_tag_1(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
my_html = '''
|
my_html = '''
|
||||||
|
|
Loading…
Reference in New Issue