mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-07-21 23:10:34 +02:00
[pp/exec] Restrict --exec template usage to safe conversions (#16883)
Authored by: bashonly
This commit is contained in:
@@ -5,8 +5,17 @@ from ..utils import Popen, PostProcessingError, shell_quote, variadic
|
||||
class ExecPP(PostProcessor):
|
||||
|
||||
def __init__(self, downloader, exec_cmd):
|
||||
PostProcessor.__init__(self, downloader)
|
||||
# Need to set exec_cmd attribute before set_downloader is called by PostProcessor.__init__
|
||||
self.exec_cmd = variadic(exec_cmd)
|
||||
PostProcessor.__init__(self, downloader)
|
||||
|
||||
def set_downloader(self, downloader):
|
||||
super().set_downloader(downloader)
|
||||
# Validate safety of exec commands
|
||||
params = getattr(self._downloader, 'params', None)
|
||||
if params and 'allow-unsafe-exec-expansion' not in params['compat_opts']:
|
||||
for cmd in self.exec_cmd:
|
||||
_ = self._downloader.prepare_outtmpl(cmd, {}, _exec=True)
|
||||
|
||||
def parse_cmd(self, cmd, info):
|
||||
tmpl, tmpl_dict = self._downloader.prepare_outtmpl(cmd, info)
|
||||
|
||||
Reference in New Issue
Block a user