form: don't break on emails with empty parts in domain (#6796)
This commit is contained in:
parent
4962adb525
commit
b6ccb50c2a
|
@ -234,6 +234,9 @@ def test_emailwidget():
|
|||
mock_form_submission(req, widget, {'test': 'foo@localhost@test'})
|
||||
assert widget.has_error()
|
||||
|
||||
widget = EmailWidget('test')
|
||||
mock_form_submission(req, widget, {'test': 'foo@localhost..localdomain'})
|
||||
assert widget.has_error()
|
||||
|
||||
def test_date_widget():
|
||||
widget = DateWidget('test')
|
||||
|
|
|
@ -709,6 +709,11 @@ class EmailWidget(StringWidget):
|
|||
elif get_cfg('emails', {}).get('check_domain_with_dns', True):
|
||||
# testing for domain existence
|
||||
domain = self.value.split('@')[-1]
|
||||
if [x for x in domain.split('.') if not x]:
|
||||
# empty parts in domain, ex: @example..net, or
|
||||
# @.example.net
|
||||
self.error = _('invalid address domain')
|
||||
return
|
||||
if not type(domain) is unicode:
|
||||
domain = unicode(domain, 'utf-8', 'ignore')
|
||||
domain = domain.encode('idna')
|
||||
|
|
Loading…
Reference in New Issue