镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/validators/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def email(
rfc_2782=rfc_2782,
)
)
if re.match(
if re.fullmatch( # 2026-10-11: Validate the complete local part.
# extended latin
r"(^[\u0100-\u017F\u0180-\u024F\u00A0-\u00FF]"
# dot-atom
Expand Down
10 changes: 10 additions & 0 deletions tests/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,13 @@ def test_returns_true_on_valid_email(value: str):
def test_returns_failed_validation_on_invalid_email(value: str):
"""Test returns failed validation on invalid email."""
assert isinstance(email(value), ValidationError)


@pytest.mark.parametrize(
"local_part", ["person", "person.name", "\u0141\u00f3ka\u015b\u0107", '"person"']
)
def test_rejects_newline_after_local_part(local_part: str):
"""Test the whole local part, including its final character."""
# 2026-10-11: A newline before the at-sign is not part of a valid local part.
assert email(f"{local_part}@example.com") is True
assert isinstance(email(f"{local_part}\n@example.com"), ValidationError)