Re: email validation problems
"Jacob Smullyan" <[email protected]>
| Newsgroups | gmane.comp.python.formencode |
|---|---|
| Message-ID | <[email protected]> |
Bad gmail! Re-attaching.... On 4/30/07, JosephSheedy <[email protected]> wrote: > > Thanks Jacob! > It looks like the patch didn't make it through though. > > --Joseph > > On Sun, Apr 29, 2007 at 05:22:55PM -0400, Jacob Smullyan wrote: > > Oy. This was my patch and my bad. > > > > The intention was to accept valid email domains that have an A record > > and not an MX. > > The following does the right thing: > > > > a=DNS.DnsRequest(domain, qtype='mx').req().answers > > if not a: > > a=DNS.DnsRequest(domain, qtype='a').req().answers > > dnsdomains=[x['data'] for x in a] > > > > Sorry for the error. An equivalent patch is attached. > > > > Jacob S. > > > > On 4/29/07, Robert Leftwich <[email protected]> wrote: > > > > > >JosephSheedy <josephs@3t...> - 2007-04-26 01:34 wrote: > > > > > >> I'm using the Email validator, and experiencing some trouble with domain > > >> resolution. After having some intermittent failures, I > > >> made a simple fuzz tester and found an address which doesn't work. > > >> So as not to generate any extra spam traffic for these guys, replace > > >'??' with > > >> 'taker' below : > > > > > >> However, I can dig their MX records just fine. I think it's a > > >> pyDNS issue, but I'm not sure. > > > > > >I ran into the same issue where the 0.7.1 release failed validation on > > >some email addresses that an earlier release did not. Some digging > > >showed that the latest code uses the following pyDNS request: > > > > > > a=DNS.DnsRequest(domain).req().answers > > > dnsdomains=[x['data'] for x in a if x['typename'] in > > > ('A', 'MX')] > > > > > >but pyDNS defaults to only looking for A records and if the domain only > > >has MX records then it will fail. Changing the code in validators.py to: > > > > > > a=DNS.DnsRequest(domain, qtype = 'mx').req().answers > > > dnsdomains=[x['data'] for x in a if x['typename'] in > > > ('A', 'MX')] > > > > > >fixes my problem (and works for the 'taker' domain as well). > > > > > >However, not knowing what Ian had in mind when making this change I > > >don't know if this is the best fix for the problem? > > > > > >Robert > > > > > >------------------------------------------------------------------------- > > >This SF.net email is sponsored by DB2 Express > > >Download DB2 Express C - the FREE version of DB2 express and take > > >control of your XML. No limits. Just data. Click to get it now. > > >http://sourceforge.net/powerbar/db2/ > > >_______________________________________________ > > >FormEncode-discuss mailing list > > >FormEncode-discuss-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org > > >https://lists.sourceforge.net/lists/listinfo/formencode-discuss > > > > > > > > > -- > > Jacob Smullyan > > office: 212/669-3230 > > mobile: 917/576-5274 > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by DB2 Express > > Download DB2 Express C - the FREE version of DB2 express and take > > control of your XML. No limits. Just data. Click to get it now. > > http://sourceforge.net/powerbar/db2/ > > _______________________________________________ > > FormEncode-discuss mailing list > > FormEncode-discuss-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org > > https://lists.sourceforge.net/lists/listinfo/formencode-discuss > > -- Jacob Smullyan office: 212/669-3230 mobile: 917/576-5274 ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ FormEncode-discuss mailing list FormEncode-discuss-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/formencode-discuss
formencode-dns.patch
(text/x-patch, 786 B)
Index: formencode/validators.py
===================================================================
--- formencode/validators.py (revision 2614)
+++ formencode/validators.py (working copy)
@@ -1230,8 +1230,10 @@
if self.resolve_domain:
assert have_dns, "pyDNS should be available"
try:
- a=DNS.DnsRequest(domain).req().answers
- dnsdomains=[x['data'] for x in a if x['typename'] in ('A', 'MX')]
+ a=DNS.DnsRequest(domain, qtype='mx').req().answers
+ if not a:
+ a=DNS.DnsRequest(domain, qtype='a').req().answers
+ dnsdomains=[x['data'] for x in a]
except (socket.error, DNS.DNSError), e:
raise Invalid(
self.message('socketError', state, error=e),