mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-12-14 12:15:23 +00:00
Respect PATHEXT when locating JS runtime on Windows (#15117)
Fixes #15043 Authored by: Grub4K
This commit is contained in:
@@ -876,13 +876,19 @@ class Popen(subprocess.Popen):
|
||||
kwargs.setdefault('encoding', 'utf-8')
|
||||
kwargs.setdefault('errors', 'replace')
|
||||
|
||||
if shell and os.name == 'nt' and kwargs.get('executable') is None:
|
||||
if not isinstance(args, str):
|
||||
args = shell_quote(args, shell=True)
|
||||
shell = False
|
||||
# Set variable for `cmd.exe` newline escaping (see `utils.shell_quote`)
|
||||
env['='] = '"^\n\n"'
|
||||
args = f'{self.__comspec()} /Q /S /D /V:OFF /E:ON /C "{args}"'
|
||||
if os.name == 'nt' and kwargs.get('executable') is None:
|
||||
# Must apply shell escaping if we are trying to run a batch file
|
||||
# These conditions should be very specific to limit impact
|
||||
if not shell and isinstance(args, list) and args and args[0].lower().endswith(('.bat', '.cmd')):
|
||||
shell = True
|
||||
|
||||
if shell:
|
||||
if not isinstance(args, str):
|
||||
args = shell_quote(args, shell=True)
|
||||
shell = False
|
||||
# Set variable for `cmd.exe` newline escaping (see `utils.shell_quote`)
|
||||
env['='] = '"^\n\n"'
|
||||
args = f'{self.__comspec()} /Q /S /D /V:OFF /E:ON /C "{args}"'
|
||||
|
||||
super().__init__(args, *remaining, env=env, shell=shell, **kwargs, startupinfo=self._startupinfo)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user