Skip to content

reduce email validation strictness #6013

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

Merged
merged 2 commits into from
Jun 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/unit/accounts/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,18 @@ def test_invalid_email_error(self):
assert not form.validate()
assert form.email.errors.pop() == "The email address isn't valid. Try again."

def test_exotic_email_success(self):
form = forms.RegistrationForm(
data={"email": "[email protected]"},
user_service=pretend.stub(
find_userid_by_email=pretend.call_recorder(lambda _: None)
),
breach_service=pretend.stub(check_password=lambda pw, tags=None: False),
)

form.validate()
assert len(form.email.errors) == 0

def test_email_exists_error(self):
form = forms.RegistrationForm(
data={"email": "[email protected]"},
Expand Down
4 changes: 2 additions & 2 deletions warehouse/accounts/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ class NewEmailMixin:
email = wtforms.fields.html5.EmailField(
validators=[
wtforms.validators.DataRequired(),
wtforms.validators.Email(
message=("The email address isn't valid. Try again.")
wtforms.validators.Regexp(
r".+@.+\..+", message=("The email address isn't valid. Try again.")
),
]
)
Expand Down