-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-39073: validate Address parts to disallow CRLF #19007
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
38d0a15
validate address parts
epicfaace d8424e5
📜🤖 Added by blurb_it.
blurb-it[bot] de6ef8c
do validation at once, on \r and \n, refactor tests
epicfaace 950bd01
Merge branch 'val-address' of github.com:epicfaace/cpython into val-a…
epicfaace 6cac3a0
rm extra spacing
epicfaace d10d383
Add display_name test
epicfaace 81a0231
update message
epicfaace 526b750
Update Misc/NEWS.d/next/Security/2020-03-15-01-28-36.bpo-39073.6Szd3i…
epicfaace File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1437,6 +1437,25 @@ def test_il8n(self): | |
# with self.assertRaises(ValueError): | ||
# Address('foo', 'wők', 'example.com') | ||
|
||
def test_crlf_in_constructor_args_raises(self): | ||
cases = ( | ||
dict(display_name='foo\r'), | ||
dict(display_name='foo\n'), | ||
dict(display_name='foo\r\n'), | ||
dict(domain='example.com\r'), | ||
dict(domain='example.com\n'), | ||
dict(domain='example.com\r\n'), | ||
dict(username='wok\r'), | ||
dict(username='wok\n'), | ||
dict(username='wok\r\n'), | ||
dict(addr_spec='[email protected]\r'), | ||
dict(addr_spec='[email protected]\n'), | ||
dict(addr_spec='[email protected]\r\n') | ||
) | ||
for kwargs in cases: | ||
with self.subTest(kwargs=kwargs), self.assertRaisesRegex(ValueError, "invalid arguments"): | ||
Address(**kwargs) | ||
|
||
def test_non_ascii_username_in_addr_spec_raises(self): | ||
with self.assertRaises(ValueError): | ||
Address('foo', addr_spec='wő[email protected]') | ||
|
1 change: 1 addition & 0 deletions
1
Misc/NEWS.d/next/Security/2020-03-15-01-28-36.bpo-39073.6Szd3i.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Disallow CR or LF in email.headerregistry.Address arguments to guard against header injection attacks. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.