kopia lustrzana https://github.com/yt-dlp/yt-dlp
Porównaj commity
4 Commity
dfa1a36423
...
a38f677d0c
Autor | SHA1 | Data |
---|---|---|
Roeniss Moon | a38f677d0c | |
Simon Sawicki | 64766459e3 | |
bashonly | 89f535e265 | |
Roeniss Moon | 9843cd4eaa |
|
@ -53,7 +53,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
- name: Install test requirements
|
- name: Install test requirements
|
||||||
run: python3 ./devscripts/install_deps.py --include dev --include curl_cffi
|
run: python3 ./devscripts/install_deps.py --include dev --include curl-cffi
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
continue-on-error: False
|
continue-on-error: False
|
||||||
run: |
|
run: |
|
||||||
|
|
|
@ -666,7 +666,7 @@ If you fork the project on GitHub, you can run your fork's [build workflow](.git
|
||||||
The name of the browser to load cookies
|
The name of the browser to load cookies
|
||||||
from. Currently supported browsers are:
|
from. Currently supported browsers are:
|
||||||
brave, chrome, chromium, edge, firefox,
|
brave, chrome, chromium, edge, firefox,
|
||||||
opera, safari, vivaldi. Optionally, the
|
opera, safari, vivaldi, whale. Optionally, the
|
||||||
KEYRING used for decrypting Chromium cookies
|
KEYRING used for decrypting Chromium cookies
|
||||||
on Linux, the name/path of the PROFILE to
|
on Linux, the name/path of the PROFILE to
|
||||||
load cookies from, and the CONTAINER name
|
load cookies from, and the CONTAINER name
|
||||||
|
|
|
@ -2059,7 +2059,22 @@ Line 1
|
||||||
assert extract_basic_auth('http://user:pass@foo.bar') == ('http://foo.bar', 'Basic dXNlcjpwYXNz')
|
assert extract_basic_auth('http://user:pass@foo.bar') == ('http://foo.bar', 'Basic dXNlcjpwYXNz')
|
||||||
|
|
||||||
@unittest.skipUnless(compat_os_name == 'nt', 'Only relevant on Windows')
|
@unittest.skipUnless(compat_os_name == 'nt', 'Only relevant on Windows')
|
||||||
def test_Popen_windows_escaping(self):
|
def test_windows_escaping(self):
|
||||||
|
tests = [
|
||||||
|
'test"&',
|
||||||
|
'%CMDCMDLINE:~-1%&',
|
||||||
|
'a\nb',
|
||||||
|
'"',
|
||||||
|
'\\',
|
||||||
|
'!',
|
||||||
|
'^!',
|
||||||
|
'a \\ b',
|
||||||
|
'a \\" b',
|
||||||
|
'a \\ b\\',
|
||||||
|
# We replace \r with \n
|
||||||
|
('a\r\ra', 'a\n\na'),
|
||||||
|
]
|
||||||
|
|
||||||
def run_shell(args):
|
def run_shell(args):
|
||||||
stdout, stderr, error = Popen.run(
|
stdout, stderr, error = Popen.run(
|
||||||
args, text=True, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
args, text=True, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
@ -2067,15 +2082,18 @@ Line 1
|
||||||
assert not error
|
assert not error
|
||||||
return stdout
|
return stdout
|
||||||
|
|
||||||
# Test escaping
|
for argument in tests:
|
||||||
assert run_shell(['echo', 'test"&']) == '"test""&"\n'
|
if isinstance(argument, str):
|
||||||
assert run_shell(['echo', '%CMDCMDLINE:~-1%&']) == '"%CMDCMDLINE:~-1%&"\n'
|
expected = argument
|
||||||
assert run_shell(['echo', 'a\nb']) == '"a"\n"b"\n'
|
else:
|
||||||
assert run_shell(['echo', '"']) == '""""\n'
|
argument, expected = argument
|
||||||
assert run_shell(['echo', '\\']) == '\\\n'
|
|
||||||
# Test if delayed expansion is disabled
|
args = [sys.executable, '-c', 'import sys; print(end=sys.argv[1])', argument, 'end']
|
||||||
assert run_shell(['echo', '^!']) == '"^!"\n'
|
assert run_shell(args) == expected
|
||||||
assert run_shell('echo "^!"') == '"^!"\n'
|
|
||||||
|
escaped = shell_quote(argument, shell=True)
|
||||||
|
args = f'{sys.executable} -c "import sys; print(end=sys.argv[1])" {escaped} end'
|
||||||
|
assert run_shell(args) == expected
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -46,7 +46,7 @@ from .utils import (
|
||||||
from .utils._utils import _YDLLogger
|
from .utils._utils import _YDLLogger
|
||||||
from .utils.networking import normalize_url
|
from .utils.networking import normalize_url
|
||||||
|
|
||||||
CHROMIUM_BASED_BROWSERS = {'brave', 'chrome', 'chromium', 'edge', 'opera', 'vivaldi'}
|
CHROMIUM_BASED_BROWSERS = {'brave', 'chrome', 'chromium', 'edge', 'opera', 'vivaldi', 'whale'}
|
||||||
SUPPORTED_BROWSERS = CHROMIUM_BASED_BROWSERS | {'firefox', 'safari'}
|
SUPPORTED_BROWSERS = CHROMIUM_BASED_BROWSERS | {'firefox', 'safari'}
|
||||||
|
|
||||||
|
|
||||||
|
@ -219,6 +219,7 @@ def _get_chromium_based_browser_settings(browser_name):
|
||||||
'edge': os.path.join(appdata_local, R'Microsoft\Edge\User Data'),
|
'edge': os.path.join(appdata_local, R'Microsoft\Edge\User Data'),
|
||||||
'opera': os.path.join(appdata_roaming, R'Opera Software\Opera Stable'),
|
'opera': os.path.join(appdata_roaming, R'Opera Software\Opera Stable'),
|
||||||
'vivaldi': os.path.join(appdata_local, R'Vivaldi\User Data'),
|
'vivaldi': os.path.join(appdata_local, R'Vivaldi\User Data'),
|
||||||
|
'whale': os.path.join(appdata_local, R'Naver\Naver Whale\User Data'),
|
||||||
}[browser_name]
|
}[browser_name]
|
||||||
|
|
||||||
elif sys.platform == 'darwin':
|
elif sys.platform == 'darwin':
|
||||||
|
@ -230,6 +231,7 @@ def _get_chromium_based_browser_settings(browser_name):
|
||||||
'edge': os.path.join(appdata, 'Microsoft Edge'),
|
'edge': os.path.join(appdata, 'Microsoft Edge'),
|
||||||
'opera': os.path.join(appdata, 'com.operasoftware.Opera'),
|
'opera': os.path.join(appdata, 'com.operasoftware.Opera'),
|
||||||
'vivaldi': os.path.join(appdata, 'Vivaldi'),
|
'vivaldi': os.path.join(appdata, 'Vivaldi'),
|
||||||
|
'whale': os.path.join(appdata, 'Naver/Whale'),
|
||||||
}[browser_name]
|
}[browser_name]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
@ -241,6 +243,7 @@ def _get_chromium_based_browser_settings(browser_name):
|
||||||
'edge': os.path.join(config, 'microsoft-edge'),
|
'edge': os.path.join(config, 'microsoft-edge'),
|
||||||
'opera': os.path.join(config, 'opera'),
|
'opera': os.path.join(config, 'opera'),
|
||||||
'vivaldi': os.path.join(config, 'vivaldi'),
|
'vivaldi': os.path.join(config, 'vivaldi'),
|
||||||
|
'whale': os.path.join(config, 'naver-whale'),
|
||||||
}[browser_name]
|
}[browser_name]
|
||||||
|
|
||||||
# Linux keyring names can be determined by snooping on dbus while opening the browser in KDE:
|
# Linux keyring names can be determined by snooping on dbus while opening the browser in KDE:
|
||||||
|
@ -252,6 +255,7 @@ def _get_chromium_based_browser_settings(browser_name):
|
||||||
'edge': 'Microsoft Edge' if sys.platform == 'darwin' else 'Chromium',
|
'edge': 'Microsoft Edge' if sys.platform == 'darwin' else 'Chromium',
|
||||||
'opera': 'Opera' if sys.platform == 'darwin' else 'Chromium',
|
'opera': 'Opera' if sys.platform == 'darwin' else 'Chromium',
|
||||||
'vivaldi': 'Vivaldi' if sys.platform == 'darwin' else 'Chrome',
|
'vivaldi': 'Vivaldi' if sys.platform == 'darwin' else 'Chrome',
|
||||||
|
'whale': 'Whale',
|
||||||
}[browser_name]
|
}[browser_name]
|
||||||
|
|
||||||
browsers_without_profiles = {'opera'}
|
browsers_without_profiles = {'opera'}
|
||||||
|
|
|
@ -1638,16 +1638,14 @@ def get_filesystem_encoding():
|
||||||
return encoding if encoding is not None else 'utf-8'
|
return encoding if encoding is not None else 'utf-8'
|
||||||
|
|
||||||
|
|
||||||
_WINDOWS_QUOTE_TRANS = str.maketrans({'"': '\\"', '\\': '\\\\'})
|
_WINDOWS_QUOTE_TRANS = str.maketrans({'"': R'\"'})
|
||||||
_CMD_QUOTE_TRANS = str.maketrans({
|
_CMD_QUOTE_TRANS = str.maketrans({
|
||||||
# Keep quotes balanced by replacing them with `""` instead of `\\"`
|
# Keep quotes balanced by replacing them with `""` instead of `\\"`
|
||||||
'"': '""',
|
'"': '""',
|
||||||
# Requires a variable `=` containing `"^\n\n"` (set in `utils.Popen`)
|
# These require an env-variable `=` containing `"^\n\n"` (set in `utils.Popen`)
|
||||||
# `=` should be unique since variables containing `=` cannot be set using cmd
|
# `=` should be unique since variables containing `=` cannot be set using cmd
|
||||||
'\n': '%=%',
|
'\n': '%=%',
|
||||||
# While we are only required to escape backslashes immediately before quotes,
|
'\r': '%=%',
|
||||||
# we instead escape all of 'em anyways to be consistent
|
|
||||||
'\\': '\\\\',
|
|
||||||
# Use zero length variable replacement so `%` doesn't get expanded
|
# Use zero length variable replacement so `%` doesn't get expanded
|
||||||
# `cd` is always set as long as extensions are enabled (`/E:ON` in `utils.Popen`)
|
# `cd` is always set as long as extensions are enabled (`/E:ON` in `utils.Popen`)
|
||||||
'%': '%%cd:~,%',
|
'%': '%%cd:~,%',
|
||||||
|
@ -1656,19 +1654,14 @@ _CMD_QUOTE_TRANS = str.maketrans({
|
||||||
|
|
||||||
def shell_quote(args, *, shell=False):
|
def shell_quote(args, *, shell=False):
|
||||||
args = list(variadic(args))
|
args = list(variadic(args))
|
||||||
if any(isinstance(item, bytes) for item in args):
|
|
||||||
deprecation_warning('Passing bytes to utils.shell_quote is deprecated')
|
|
||||||
encoding = get_filesystem_encoding()
|
|
||||||
for index, item in enumerate(args):
|
|
||||||
if isinstance(item, bytes):
|
|
||||||
args[index] = item.decode(encoding)
|
|
||||||
|
|
||||||
if compat_os_name != 'nt':
|
if compat_os_name != 'nt':
|
||||||
return shlex.join(args)
|
return shlex.join(args)
|
||||||
|
|
||||||
trans = _CMD_QUOTE_TRANS if shell else _WINDOWS_QUOTE_TRANS
|
trans = _CMD_QUOTE_TRANS if shell else _WINDOWS_QUOTE_TRANS
|
||||||
return ' '.join(
|
return ' '.join(
|
||||||
s if re.fullmatch(r'[\w#$*\-+./:?@\\]+', s, re.ASCII) else s.translate(trans).join('""')
|
s if re.fullmatch(r'[\w#$*\-+./:?@\\]+', s, re.ASCII)
|
||||||
|
else re.sub(r'(\\+)("|$)', r'\1\1\2', s).translate(trans).join('""')
|
||||||
for s in args)
|
for s in args)
|
||||||
|
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue