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

Account for a cached value of False when validating. #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dmpayton
Copy link

Hi there,

I had an issue on django-flanker that I've traced to flanker itself.

dmpayton/django-flanker#2

If connect_to_mail_exchanger throws an exception or fails to connect for whatever, it returns None and mail_exchanger_lookup will set mx_cache[domain] to False.

This is not accounted for on subsequent calls to validate_address. If the cached value is None, it returns None, otherwise it continues. If the cached value is False, it throws the following exception:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/derek/dev/django-flanker/flanker/utils.py", line 99, in wrapper
    return_value = f(*args, **kwargs)
  File "/home/derek/dev/django-flanker/flanker/addresslib/address.py", line 205, in validate_address
    plugin = flanker.addresslib.validate.plugin_for_esp(exchanger)
  File "/home/derek/dev/django-flanker/flanker/addresslib/validate.py", line 108, in plugin_for_esp
    if grammar[0].match(mail_exchanger):
TypeError: expected string or buffer

This patch simply returns None if the cached value is False.

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

Successfully merging this pull request may close these issues.

1 participant