domain can ends with dot
This commit is contained in:
parent
8658fdd6ca
commit
3fe77f7e65
2 changed files with 11 additions and 2 deletions
|
@ -114,6 +114,7 @@ async def test_domainname_warning(config_type):
|
||||||
await cfg.property.read_write()
|
await cfg.property.read_write()
|
||||||
cfg = await get_config(cfg, config_type)
|
cfg = await get_config(cfg, config_type)
|
||||||
await cfg.option('d').value.set('toto.com')
|
await cfg.option('d').value.set('toto.com')
|
||||||
|
await cfg.option('d').value.set('toto.com.')
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
await cfg.option('d').value.set('toto')
|
await cfg.option('d').value.set('toto')
|
||||||
await cfg.option('d').value.set('toto3.com')
|
await cfg.option('d').value.set('toto3.com')
|
||||||
|
|
|
@ -138,7 +138,11 @@ class DomainnameOption(StrOption):
|
||||||
val = value[1:]
|
val = value[1:]
|
||||||
else:
|
else:
|
||||||
val = value
|
val = value
|
||||||
for dom in val.split('.'):
|
if val.endswith('.'):
|
||||||
|
nval = val[:-1]
|
||||||
|
else:
|
||||||
|
nval = val
|
||||||
|
for dom in nval.split('.'):
|
||||||
_valid_length(dom)
|
_valid_length(dom)
|
||||||
else:
|
else:
|
||||||
_valid_length(value)
|
_valid_length(value)
|
||||||
|
@ -179,7 +183,11 @@ class DomainnameOption(StrOption):
|
||||||
val = value[1:]
|
val = value[1:]
|
||||||
else:
|
else:
|
||||||
val = value
|
val = value
|
||||||
if not self.impl_get_extra('_domain_re').search(val):
|
if val.endswith('.'):
|
||||||
|
nval = val[:-1]
|
||||||
|
else:
|
||||||
|
nval = val
|
||||||
|
if not self.impl_get_extra('_domain_re').search(nval):
|
||||||
if warnings_only:
|
if warnings_only:
|
||||||
raise ValueError(self.impl_get_extra('_domain_re_message_warning'))
|
raise ValueError(self.impl_get_extra('_domain_re_message_warning'))
|
||||||
raise ValueError(self.impl_get_extra('_domain_re_message'))
|
raise ValueError(self.impl_get_extra('_domain_re_message'))
|
||||||
|
|
Loading…
Reference in a new issue