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

Appearance settings
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions 10 Lib/test/test_urlparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,16 @@ def test_splithost(self):
self.assertEqual(splithost("//example.net/file#"),
('example.net', '/file#'))

# bpo-35906: disallow line breaks
self.assertEqual(splithost('//127.0.0.1:1234/?q=HTTP/1.1\r\nHeader: Value'),
(None, '//127.0.0.1:1234/?q=HTTP/1.1\r\nHeader: Value'))

self.assertEqual(splithost('//127.0.0.1:1234?q=HTTP/1.1\r\nHeader: Value'),
(None, '//127.0.0.1:1234?q=HTTP/1.1\r\nHeader: Value'))

self.assertEqual(splithost('//127.0.0.1:1234#q=HTTP/1.1\r\nHeader: Value'),
(None, '//127.0.0.1:1234#q=HTTP/1.1\r\nHeader: Value'))

def test_splituser(self):
splituser = urllib.parse._splituser
self.assertEqual(splituser('User:Pass@www.python.org:080'),
Expand Down
2 changes: 1 addition & 1 deletion 2 Lib/urllib/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ def _splithost(url):
"""splithost('//host[:port]/path') --> 'host[:port]', '/path'."""
global _hostprog
if _hostprog is None:
_hostprog = re.compile('//([^/#?]*)(.*)', re.DOTALL)
_hostprog = re.compile('//([^/#?]*)(.*)$')

match = _hostprog.match(url)
if match:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix CRLF injection in urllib as disallowing line breaks in parse
Morty Proxy This is a proxified and sanitized view of the page, visit original site.