Skip to content

Commit

Permalink
Change email regex match to fullmatch
Browse files Browse the repository at this point in the history
This PR is about the current method used to conditionally match user and domain regex to email.
currently, it's using match which wrongfully accepts entries if domain has special characters after .com

it currently accepts, john@voluptuous.com> or john!@voluptuous.org!@($*!

thus, we need to fullmatch the domain or user to avoid such entries and validate them properly.
  • Loading branch information
leonidguadalupe authored and alecthomas committed Aug 31, 2021
1 parent 1720439 commit e5e3b51
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion voluptuous/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ def Email(v):
raise EmailInvalid("Invalid email address")
user_part, domain_part = v.rsplit('@', 1)

if not (USER_REGEX.match(user_part) and DOMAIN_REGEX.match(domain_part)):
if not (USER_REGEX.fullmatch(user_part) and DOMAIN_REGEX.fullmatch(domain_part)):

This comment has been minimized.

Copy link
@shadchin

shadchin Sep 24, 2021

JFYI: Python 2 does not support fullmatch

raise EmailInvalid("Invalid email address")
return v
except:
Expand Down

0 comments on commit e5e3b51

Please sign in to comment.