mdipierro / evote

A system for secure, trusted, and verifiable voting on the web
Other
117 stars 41 forks source link

Email addresses with "+" in them are not valid in the email regex #21

Closed sigmavirus24 closed 8 years ago

sigmavirus24 commented 9 years ago

See https://github.com/mdipierro/evote/blob/8b48a6d449bbc1f10f34e94aafee660bf9197435/modules/ballot.py#L13 for more details

>>> regex_email.findall('test+foo@gmail.com')
['foo@gmail.com']
patilise commented 9 years ago

Adapting from web2py's validator module (which adapted from I Knew How To Validate An Email Address Until I Read The RFC), the following expression works:

regex_email = re.compile('''^((?!\.)(?:[-a-z0-9!\#$%&'*+/=?^_`{|}~]|(?<!\.)\.)+(?<!\.)@(?:localhost|(?:[a-z0-9](?:[-\w]*[a-z0-9])?\.)+[a-z]{2,}))$''', re.IGNORECASE)

Although, it is not clear whether it is a good idea to support all email addresses allowed in RFC 822.

sigmavirus24 commented 9 years ago

Helios uses a separate package to manage it: https://github.com/benadida/helios-server/blob/master/requirements.txt#L25 Instead of trying to maintain this ourselves, I would suggest that if we want to validate email addresses, we should use a package that is maintained and used by peers.

mdipierro commented 9 years ago

I agree. BTW. web2py has a very good one and we have been maintaining it for here. Now sure why we are not use that since we are using the framework. I will fix it.

sigmavirus24 commented 9 years ago

:+1: thanks @mdipierro

mdipierro commented 8 years ago

Fixed here: https://github.com/mdipierro/evote/commit/6a09833d5361cb43c16cb70f42f06df2f5af0fa6