0001-email-validation-verify-only-MX-with-a-7s-timeout-43.patch
wcs/qommon/form.py | ||
---|---|---|
44 | 44 | |
45 | 45 |
try: |
46 | 46 |
import DNS |
47 |
DNS.ParseResolvConf() |
|
48 | 47 |
except (ImportError, IOError): |
49 | 48 |
DNS = None |
50 | 49 | |
... | ... | |
900 | 899 |
except UnicodeError: |
901 | 900 |
self.error = _('invalid address domain') |
902 | 901 |
return |
903 |
# simply lookup host name; note it will fail if hostname |
|
904 |
# doesn't have an A entry |
|
905 |
try: |
|
906 |
socket.gethostbyname(domain) |
|
907 |
except socket.error: |
|
908 |
# will fail on lack of DNS module or MX lookup failure |
|
902 |
if domain == 'localhost': |
|
903 |
return |
|
904 |
if DNS is not None: |
|
905 |
DNS.ParseResolvConf() |
|
909 | 906 |
try: |
910 |
l = len(DNS.mxlookup(force_str(domain))) |
|
911 |
except: |
|
912 |
l = 0 |
|
913 |
if l == 0: |
|
907 |
if not DNS.mxlookup(force_str(domain), timeout=7): |
|
908 |
self.error = _('invalid address domain') |
|
909 |
except DNS.DNSError: |
|
914 | 910 |
self.error = _('invalid address domain') |
915 |
else: |
|
916 |
# and then, localpart could be tested |
|
917 |
pass |
|
918 | 911 | |
919 | 912 | |
920 | 913 |
class ValidationCondition(Condition): |
921 |
- |