镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Reject a trailing newline in email local parts - #503

Open
fhgffy wants to merge 1 commit into
python-validators:masterfrom
fhgffy:fix/email-local-part-newline-20261011
Open

fhgffy wants to merge 1 commit into
python-validators:masterfrom
fhgffy:fix/email-local-part-newline-20261011

Conversation

@fhgffy

@fhgffy fhgffy commented Oct 10, 2026

Copy link
Copy Markdown

The local-part pattern accepts a final newline before the at-sign because re.match() and $ can leave that character unconsumed. For example, email("person\n@example.com") currently returns True.

Use re.fullmatch() to require the local part to consume the entire value. The regression covers an ordinary name, a dotted name, an extended-Latin name, and a quoted name, with valid controls for each. All four newline cases fail on the unchanged source.

On Python 3.12.2, pytest . -q passes with 1131 tests. Ruff lint and format checks, Pyright, Bandit, and wheel/sdist builds also pass.

The open terminal-newline fix in #501 covers MAC and regional identifier validators; this change covers email local parts.

This branch has not been deployed

No deployments
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