-
-
Notifications
You must be signed in to change notification settings - Fork 34.7k
gh-150479: reject CR and LF in email.utils.formataddr #150480
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
base: main
Are you sure you want to change the base?
Changes from all commits
1ba88a3
3c4527c
b4bbd19
d51ab23
0e91fe3
f86e43d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -70,7 +70,7 @@ of the new API. | |||||
| Add *strict* optional parameter and reject malformed inputs by default. | ||||||
|
|
||||||
|
|
||||||
| .. function:: formataddr(pair, charset='utf-8') | ||||||
| .. function:: formataddr(pair, charset='utf-8', *, strict=True) | ||||||
|
|
||||||
| The inverse of :meth:`parseaddr`, this takes a 2-tuple of the form ``(realname, | ||||||
| email_address)`` and returns the string value suitable for a :mailheader:`To` or | ||||||
|
|
@@ -82,9 +82,16 @@ of the new API. | |||||
| characters. Can be an instance of :class:`str` or a | ||||||
| :class:`~email.charset.Charset`. Defaults to ``utf-8``. | ||||||
|
|
||||||
| If *strict* is true (the default), raise :exc:`ValueError` for inputs that | ||||||
| contain CR or LF, which are not allowed in an email address. Set *strict* | ||||||
| to ``False`` to allow non-strict inputs. | ||||||
|
|
||||||
| .. versionchanged:: 3.3 | ||||||
| Added the *charset* option. | ||||||
|
|
||||||
| .. versionchanged:: 3.16 | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| Added the *strict* parameter. | ||||||
|
|
||||||
|
|
||||||
| .. function:: getaddresses(fieldvalues, *, strict=True) | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| :func:`email.utils.formataddr` now raises :exc:`ValueError` when the name or | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not a security NEWS..Please move it to Library. |
||
| address contains a carriage return or line feed, preventing header injection | ||
| and matching :class:`email.headerregistry.Address`. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please mention that this can be disabled by passing strict=False. |
||
Uh oh!
There was an error while loading. Please reload this page.