Skip to content

Commit fc8b6c8

Browse files
gh-XXXXX: Fix smtplib.quoteaddr() returning malformed address for '<'
Input starting with '<' but missing closing '>' was returned verbatim. Ensure the result always ends with '>'.
1 parent 0c29f83 commit fc8b6c8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Lib/smtplib.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ def quoteaddr(addrstring):
150150
if (displayname, addr) == ('', ''):
151151
# parseaddr couldn't parse it, use it as is and hope for the best.
152152
if addrstring.strip().startswith('<'):
153-
return addrstring
153+
if addrstring.strip().endswith('>'):
154+
return addrstring
155+
return addrstring.strip() + '>'
154156
return "<%s>" % addrstring
155157
return "<%s>" % addr
156158

0 commit comments

Comments
 (0)