domain can ends with dot

This commit is contained in:
Emmanuel Garette 2022-01-09 19:12:37 +01:00
parent 8658fdd6ca
commit 3fe77f7e65
2 changed files with 11 additions and 2 deletions

View file

@ -114,6 +114,7 @@ async def test_domainname_warning(config_type):
await cfg.property.read_write()
cfg = await get_config(cfg, config_type)
await cfg.option('d').value.set('toto.com')
await cfg.option('d').value.set('toto.com.')
with pytest.raises(ValueError):
await cfg.option('d').value.set('toto')
await cfg.option('d').value.set('toto3.com')

View file

@ -138,7 +138,11 @@ class DomainnameOption(StrOption):
val = value[1:]
else:
val = value
for dom in val.split('.'):
if val.endswith('.'):
nval = val[:-1]
else:
nval = val
for dom in nval.split('.'):
_valid_length(dom)
else:
_valid_length(value)
@ -179,7 +183,11 @@ class DomainnameOption(StrOption):
val = value[1:]
else:
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:
raise ValueError(self.impl_get_extra('_domain_re_message_warning'))
raise ValueError(self.impl_get_extra('_domain_re_message'))