-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes "nonnumeric port" errors when youtube-dl is given URLs with usernames and passwords such as: http://username:[email protected]/myvideo.mp4 Refs: - https://en.wikipedia.org/wiki/Basic_access_authentication - https://tools.ietf.org/html/rfc1738#section-3.1 - https://docs.python.org/3.8/library/urllib.parse.html#urllib.parse.urlsplit Fixes #18276 (point 4) Fixes #20258 Fixes #26211 (see comment)
- Loading branch information
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -65,6 +65,8 @@ | |
sanitize_filename, | ||
sanitize_path, | ||
sanitize_url, | ||
extract_user_pass, | ||
sanitized_Request, | ||
expand_path, | ||
prepend_extension, | ||
replace_extension, | ||
|
@@ -237,6 +239,26 @@ def test_sanitize_url(self): | |
self.assertEqual(sanitize_url('rmtps://foo.bar'), 'rtmps://foo.bar') | ||
self.assertEqual(sanitize_url('https://foo.bar'), 'https://foo.bar') | ||
|
||
def test_extract_user_pass(self): | ||
self.assertEqual(extract_user_pass('http://foo.bar'), ('http://foo.bar', None, None)) | ||
self.assertEqual(extract_user_pass('http://:foo.bar'), ('http://:foo.bar', None, None)) | ||
self.assertEqual(extract_user_pass('http://@foo.bar'), ('http://foo.bar', '', '')) | ||
self.assertEqual(extract_user_pass('http://:[email protected]'), ('http://foo.bar', '', 'pass')) | ||
self.assertEqual(extract_user_pass('http://user:@foo.bar'), ('http://foo.bar', 'user', '')) | ||
self.assertEqual(extract_user_pass('http://user:[email protected]'), ('http://foo.bar', 'user', 'pass')) | ||
|
||
def test_sanitized_Request(self): | ||
self.assertFalse(sanitized_Request('http://foo.bar').has_header('Authorization')) | ||
self.assertFalse(sanitized_Request('http://:foo.bar').has_header('Authorization')) | ||
self.assertEqual(sanitized_Request('http://@foo.bar').get_header('Authorization'), | ||
'Basic Og==') | ||
self.assertEqual(sanitized_Request('http://:[email protected]').get_header('Authorization'), | ||
'Basic OnBhc3M=') | ||
self.assertEqual(sanitized_Request('http://user:@foo.bar').get_header('Authorization'), | ||
'Basic dXNlcjo=') | ||
self.assertEqual(sanitized_Request('http://user:[email protected]').get_header('Authorization'), | ||
'Basic dXNlcjpwYXNz') | ||
|
||
def test_expand_path(self): | ||
def env(var): | ||
return '%{0}%'.format(var) if sys.platform == 'win32' else '${0}'.format(var) | ||
|
This file contains 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