configtypes: Handle max. recursion depth for Regex.
This commit is contained in:
parent
2c7b0d2fb4
commit
702842c977
@ -60,6 +60,9 @@ def _validate_regex(pattern, flags):
|
|||||||
except re.error as e:
|
except re.error as e:
|
||||||
raise configexc.ValidationError(
|
raise configexc.ValidationError(
|
||||||
pattern, "must be a valid regex - " + str(e))
|
pattern, "must be a valid regex - " + str(e))
|
||||||
|
except RuntimeError:
|
||||||
|
raise configexc.ValidationError(
|
||||||
|
pattern, "must be a valid regex - recursion depth exceeded")
|
||||||
|
|
||||||
for w in recorded_warnings:
|
for w in recorded_warnings:
|
||||||
if (issubclass(w.category, DeprecationWarning) and
|
if (issubclass(w.category, DeprecationWarning) and
|
||||||
|
@ -1149,7 +1149,7 @@ class TestRegex:
|
|||||||
def test_validate_valid(self, klass, val):
|
def test_validate_valid(self, klass, val):
|
||||||
klass(none_ok=True).validate(val)
|
klass(none_ok=True).validate(val)
|
||||||
|
|
||||||
@pytest.mark.parametrize('val', [r'(foo|bar))?baz[fis]h', ''])
|
@pytest.mark.parametrize('val', [r'(foo|bar))?baz[fis]h', '', '(' * 500])
|
||||||
def test_validate_invalid(self, klass, val):
|
def test_validate_invalid(self, klass, val):
|
||||||
with pytest.raises(configexc.ValidationError):
|
with pytest.raises(configexc.ValidationError):
|
||||||
klass().validate(val)
|
klass().validate(val)
|
||||||
@ -1225,6 +1225,7 @@ class TestRegexList:
|
|||||||
r'(foo|bar),,1337{42}',
|
r'(foo|bar),,1337{42}',
|
||||||
r'',
|
r'',
|
||||||
r'(foo|bar),((),1337{42}',
|
r'(foo|bar),((),1337{42}',
|
||||||
|
r'(' * 500,
|
||||||
])
|
])
|
||||||
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