mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-02-22 16:36:54 +00:00
[ie] Limit netrc_machine parameter to shell-safe characters
Also adapts some extractor regexes to adhere to this limitation See: https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-g3gw-q23r-pgqm Authored by: Grub4K
This commit is contained in:
@@ -661,9 +661,11 @@ class InfoExtractor:
|
||||
if not self._ready:
|
||||
self._initialize_pre_login()
|
||||
if self.supports_login():
|
||||
username, password = self._get_login_info()
|
||||
if username:
|
||||
self._perform_login(username, password)
|
||||
# try login only if it would actually do anything
|
||||
if type(self)._perform_login is not InfoExtractor._perform_login:
|
||||
username, password = self._get_login_info()
|
||||
if username:
|
||||
self._perform_login(username, password)
|
||||
elif self.get_param('username') and False not in (self.IE_DESC, self._NETRC_MACHINE):
|
||||
self.report_warning(f'Login with password is not supported for this website. {self._login_hint("cookies")}')
|
||||
self._real_initialize()
|
||||
@@ -1385,6 +1387,11 @@ class InfoExtractor:
|
||||
|
||||
def _get_netrc_login_info(self, netrc_machine=None):
|
||||
netrc_machine = netrc_machine or self._NETRC_MACHINE
|
||||
if not netrc_machine:
|
||||
raise ExtractorError(f'Missing netrc_machine and {type(self).__name__}._NETRC_MACHINE')
|
||||
ALLOWED = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_'
|
||||
if netrc_machine.startswith(('-', '_')) or not all(c in ALLOWED for c in netrc_machine):
|
||||
raise ExtractorError(f'Invalid netrc machine: {netrc_machine!r}', expected=True)
|
||||
|
||||
cmd = self.get_param('netrc_cmd')
|
||||
if cmd:
|
||||
|
||||
Reference in New Issue
Block a user