A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/python/cpython/commit/f91a0b6df14d6c5133fe3d5889fad7d84fc0c046 below:

validate Address parts to disallow CRLF (#19007) (#20450) · python/cpython@f91a0b6 · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+25

-0

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+25

-0

lines changed Original file line number Diff line number Diff line change

@@ -31,6 +31,11 @@ def __init__(self, display_name='', username='', domain='', addr_spec=None):

31 31

without any Content Transfer Encoding.

32 32 33 33

"""

34 + 35 +

inputs = ''.join(filter(None, (display_name, username, domain, addr_spec)))

36 +

if '\r' in inputs or '\n' in inputs:

37 +

raise ValueError("invalid arguments; address parts cannot contain CR or LF")

38 + 34 39

# This clause with its potential 'raise' may only happen when an

35 40

# application program creates an Address object using an addr_spec

36 41

# keyword. The email library code itself must always supply username

Original file line number Diff line number Diff line change

@@ -1415,6 +1415,25 @@ def test_il8n(self):

1415 1415

# with self.assertRaises(ValueError):

1416 1416

# Address('foo', 'wők', 'example.com')

1417 1417 1418 +

def test_crlf_in_constructor_args_raises(self):

1419 +

cases = (

1420 +

dict(display_name='foo\r'),

1421 +

dict(display_name='foo\n'),

1422 +

dict(display_name='foo\r\n'),

1423 +

dict(domain='example.com\r'),

1424 +

dict(domain='example.com\n'),

1425 +

dict(domain='example.com\r\n'),

1426 +

dict(username='wok\r'),

1427 +

dict(username='wok\n'),

1428 +

dict(username='wok\r\n'),

1429 +

dict(addr_spec='wok@example.com\r'),

1430 +

dict(addr_spec='wok@example.com\n'),

1431 +

dict(addr_spec='wok@example.com\r\n')

1432 +

)

1433 +

for kwargs in cases:

1434 +

with self.subTest(kwargs=kwargs), self.assertRaisesRegex(ValueError, "invalid arguments"):

1435 +

Address(**kwargs)

1436 + 1418 1437

def test_non_ascii_username_in_addr_spec_raises(self):

1419 1438

with self.assertRaises(ValueError):

1420 1439

Address('foo', addr_spec='wők@example.com')

Original file line number Diff line number Diff line change

@@ -0,0 +1 @@

1 +

Disallow CR or LF in email.headerregistry.Address arguments to guard against header injection attacks.

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4