api: file download: limit filename length and encode it for the worker id

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht
2021-06-23 22:40:40 +02:00
parent d0a3db1bf5
commit fc015f3d9c

View File

@ -525,6 +525,7 @@ __PACKAGE__->register_method({
}, },
filename => { filename => {
description => "The name of the file to create. Caution: This will be normalized!", description => "The name of the file to create. Caution: This will be normalized!",
maxLength => 255,
type => 'string', type => 'string',
}, },
checksum => { checksum => {
@ -607,7 +608,9 @@ __PACKAGE__->register_method({
PVE::Tools::download_file_from_url("$path/$filename", $url, $opts); PVE::Tools::download_file_from_url("$path/$filename", $url, $opts);
}; };
return $rpcenv->fork_worker('download', $filename, $user, $worker); my $worker_id = PVE::Tools::encode_text($filename); # must not pass : or the like as w-ID
return $rpcenv->fork_worker('download', $worker_id, $user, $worker);
}}); }});
1; 1;