configtypes: Handle invalid format syntax.
This commit is contained in:
parent
4bdf00b148
commit
c750ff3f50
@ -1092,6 +1092,8 @@ class SearchEngineUrl(BaseType):
|
|||||||
except (KeyError, IndexError) as e:
|
except (KeyError, IndexError) as e:
|
||||||
raise configexc.ValidationError(
|
raise configexc.ValidationError(
|
||||||
value, "may not contain {...} (use {{ and }} for literal {/})")
|
value, "may not contain {...} (use {{ and }} for literal {/})")
|
||||||
|
except ValueError as e:
|
||||||
|
raise configexc.ValidationError(value, str(e))
|
||||||
|
|
||||||
url = QUrl(value.replace('{}', 'foobar'))
|
url = QUrl(value.replace('{}', 'foobar'))
|
||||||
if not url.isValid():
|
if not url.isValid():
|
||||||
|
@ -1502,6 +1502,7 @@ class TestSearchEngineUrl:
|
|||||||
':{}', # invalid URL
|
':{}', # invalid URL
|
||||||
'foo{bar}baz{}', # {bar} format string variable
|
'foo{bar}baz{}', # {bar} format string variable
|
||||||
'{1}{}', # numbered format string variable
|
'{1}{}', # numbered format string variable
|
||||||
|
'{{}', # invalid format syntax
|
||||||
])
|
])
|
||||||
def test_validate_invalid(self, klass, val):
|
def test_validate_invalid(self, klass, val):
|
||||||
with pytest.raises(configexc.ValidationError):
|
with pytest.raises(configexc.ValidationError):
|
||||||
|
Loading…
Reference in New Issue
Block a user