email validation: verify only MX, with a 7s timeout (#43422)
This commit is contained in:
parent
2122f9d955
commit
ee2adbbf49
|
@ -44,7 +44,6 @@ except ImportError:
|
|||
|
||||
try:
|
||||
import DNS
|
||||
DNS.ParseResolvConf()
|
||||
except (ImportError, IOError):
|
||||
DNS = None
|
||||
|
||||
|
@ -900,21 +899,15 @@ class EmailWidget(StringWidget):
|
|||
except UnicodeError:
|
||||
self.error = _('invalid address domain')
|
||||
return
|
||||
# simply lookup host name; note it will fail if hostname
|
||||
# doesn't have an A entry
|
||||
try:
|
||||
socket.gethostbyname(domain)
|
||||
except socket.error:
|
||||
# will fail on lack of DNS module or MX lookup failure
|
||||
if domain == 'localhost':
|
||||
return
|
||||
if DNS is not None:
|
||||
DNS.ParseResolvConf()
|
||||
try:
|
||||
l = len(DNS.mxlookup(force_str(domain)))
|
||||
except:
|
||||
l = 0
|
||||
if l == 0:
|
||||
if not DNS.mxlookup(force_str(domain), timeout=7):
|
||||
self.error = _('invalid address domain')
|
||||
except DNS.DNSError:
|
||||
self.error = _('invalid address domain')
|
||||
else:
|
||||
# and then, localpart could be tested
|
||||
pass
|
||||
|
||||
|
||||
class ValidationCondition(Condition):
|
||||
|
|
Loading…
Reference in New Issue