Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid email is seen as "valid" #2

Closed
hongquan opened this issue Jun 14, 2014 · 9 comments
Closed

Invalid email is seen as "valid" #2

hongquan opened this issue Jun 14, 2014 · 9 comments

Comments

@hongquan
Copy link

This is weird:

In [1]: from pyisemail import is_email

In [2]: s = '08.00.27.d1.8c.d2@virtualbox'

In [3]: is_email(s, check_dns=True)
Out[3]: True
@michaelherold
Copy link
Owner

I see you're using the check_dns functionality. Is your DNS provider returning a forwarding domain? If you're using OpenDNS, I know they always return a DNS record, since they forward your requests to a holder domain. This can lead to the check being marked as valid, even when there isn't really a domain there.

@hongquan
Copy link
Author

As the same time, I check with host command:

$ host virtualbox
Host virtualbox not found: 3(NXDOMAIN)

Can it be seen that DNS provider don't return forwarding domain?

Test with Python:

import dns.resolver
dns.resolver.query('virtualbox')

Get NXDOMAIN exception.

@michaelherold
Copy link
Owner

If run is_email with the diagnose flag, you'll get an explanation as to why it's considered valid:

>>> from pyisemail import is_email
>>> s = '08.00.27.d1.8c.d2@virtualbox'
>>> d = is_email(s, check_dns=True, diagnose=True)
<RFC5321Diagnosis: TLD>
>>> d.message
'Address is valid but at a Top Level Domain.'

If you'd like more information on this diagnosis, you can read about it at the isemail.info diagnosis.

As it is, though, pyIsEmail is functioning as intended, so I'm going to go ahead and close this issue.

@hongquan
Copy link
Author

But isn't check_dns=True supposed to make sure that the domain exists? In this case, virtualbox is inexistent domain and it should be rejected.

@michaelherold
Copy link
Owner

You have a point. Since we can get more information out of dnspython than the parent library could get from its DNS resolver, we should use that information. I'm reopening this for you to check out the change I made to make sure it works for you.

@michaelherold michaelherold reopened this Jun 24, 2014
@michaelherold
Copy link
Owner

@hongquan Since I never heard back from you, I went ahead and included that fix in a new 1.1.0 version. Thanks for reporting the bug!

@hongquan
Copy link
Author

Thanks

@jace
Copy link

jace commented Sep 12, 2014

This bug still exists. check_dns only works if diagnose=True.

>>> from pyisemail import is_email
>>> is_email('jace@pobox.com', check_dns=True, diagnose=True)
<ValidDiagnosis: VALID>
>>> type(is_email('jace@pobox.com', check_dns=True, diagnose=True))
<class 'pyisemail.diagnosis.valid_diagnosis.ValidDiagnosis'>
>>> type(is_email('jace@nobox.com', check_dns=True, diagnose=True))
<class 'pyisemail.diagnosis.valid_diagnosis.ValidDiagnosis'>
>>> is_email('jace@nobox.com', check_dns=True, diagnose=True)
<ValidDiagnosis: VALID>
>>> is_email('jace@hjkjjh.com', check_dns=True, diagnose=True)
<DNSDiagnosis: NO_RECORD>
>>> is_email('jace@hjkjjh.com', check_dns=True, diagnose=False)
True
>>> is_email('jace@iuiuygbhkiu7y87gt8.com', check_dns=True, diagnose=False)
True
>>> is_email('jace@iuiuygbhkiu7y87gt8.com', check_dns=True)
True

@michaelherold
Copy link
Owner

@jace Thanks for reporting this. My apologies for not addressing it yet. I intend to, I just haven't had the time. If you'd like to write a patch, I'll be happy to review and accept it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants