Projet

Général

Profil

0001-email-validation-verify-only-MX-with-a-10s-timeout-4.patch

Thomas Noël, 28 mai 2020 16:18

Télécharger (1,73 ko)

Voir les différences:

Subject: [PATCH] email validation: verify only MX, with a 10s timeout (#43422)

 wcs/qommon/form.py | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)
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 DNS is not None:
903
                    DNS.ParseResolvConf()
909 904
                    try:
910
                        l = len(DNS.mxlookup(force_str(domain)))
911
                    except:
912
                        l = 0
913
                    if l == 0:
905
                        if not DNS.mxlookup(force_str(domain), timeout=10):
906
                            self.error = _('invalid address domain')
907
                    except DNS.DNSError:
914 908
                        self.error = _('invalid address domain')
915
                else:
916
                    # and then, localpart could be tested
917
                    pass
918 909

  
919 910

  
920 911
class ValidationCondition(Condition):
921
-