Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-145552: smtplib:quoteaddr() returns malformed address for input'<'#145553

Open
stefanzetzsche wants to merge 3 commits intopython:mainfrom
stefanzetzsche:fix/smtplib_quoteaddr_malformed
Open

gh-145552: smtplib:quoteaddr() returns malformed address for input'<'#145553
stefanzetzsche wants to merge 3 commits intopython:mainfrom
stefanzetzsche:fix/smtplib_quoteaddr_malformed

Conversation

@stefanzetzsche
Copy link

@stefanzetzschestefanzetzsche commentedMar 5, 2026
edited by bedevere-appbot
Loading

Problem

quoteaddr() formats addresses for SMTPMAIL FROM: andRCPT TO: commands, which require angle-bracket format (<addr>). It first triesemail.utils.parseaddr(); when that fails (for inputs like'<','< ','@'), a fallback path checks if the input starts with< and returns it verbatim — without verifying it also ends with>.

The fallback is intentionally lenient with unparseable input (the source comment reads "use it as is and hope for the best"), but a half-open< with no> produces structurally invalid SMTP commands.

Reproducer

fromsmtplibimportquoteaddrprint(repr(quoteaddr('<')))# '<' — missing closing >

Fix

InLib/smtplib.py, in the fallback branch ofquoteaddr, verify the string also ends with> before returning it. If not, append>:

ifaddrstring.strip().startswith('<'):ifaddrstring.strip().endswith('>'):returnaddrstringreturnaddrstring.strip()+'>'

stefanzetzscheand others added2 commitsMarch 5, 2026 15:03
Input starting with '<' but missing closing '>' was returned verbatim.Ensure the result always ends with '>'.
Add testQuoteAddr for basic quoteaddr behavior andtestQuoteAddrMalformedAngleBracket for inputs starting with '<'but missing closing '>'. The latter fails without the fix.
@bedevere-app
Copy link

Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply theskip news label instead.

@python-cla-bot
Copy link

python-cla-botbot commentedMar 5, 2026
edited
Loading

All commit authors signed the Contributor License Agreement.

CLA signed

@stefanzetzschestefanzetzsche marked this pull request as ready for reviewMarch 5, 2026 15:20
@stefanzetzschestefanzetzsche requested a review froma team as acode ownerMarch 5, 2026 15:20
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@stefanzetzsche

[8]ページ先頭

©2009-2026 Movatter.jp