misc: catch OverflowError that can be raised by django template (#41908)
This commit is contained in:
parent
064f6bbb68
commit
db7bc6dd17
|
@ -2854,6 +2854,9 @@ def test_validate_condition(pub):
|
|||
resp = get_app(pub).get('/api/validate-condition?type=django&value_django=~2')
|
||||
assert resp.json['klass'] == 'error'
|
||||
assert resp.json['msg'].startswith('syntax error')
|
||||
resp = get_app(pub).get('/api/validate-condition?type=django&value_django=%22...%22+inf') # "..." + inf
|
||||
assert resp.json['klass'] == 'error'
|
||||
assert resp.json['msg'].startswith('syntax error')
|
||||
|
||||
resp = get_app(pub).get('/api/validate-condition?type=unknown&value_unknown=2')
|
||||
assert resp.json['klass'] == 'error'
|
||||
|
|
|
@ -92,5 +92,5 @@ class Condition(object):
|
|||
def validate_django(self):
|
||||
try:
|
||||
Template('{%% if %s %%}OK{%% endif %%}' % self.value)
|
||||
except TemplateSyntaxError as e:
|
||||
except (TemplateSyntaxError, OverflowError) as e:
|
||||
raise ValidationError(_('syntax error: %s') % force_str(force_text(e)))
|
||||
|
|
Loading…
Reference in New Issue