mirror of
https://git.proxmox.com/git/pve-http-server
synced 2025-05-01 12:41:39 +00:00
upload: re-allow white space in filenames
Some fields (e.g. filename) can contain spaces, but our 'trim'
function, would only return the value until the first whitespace
character instead of removing leading/trailing white space. This lead
to passing the wrong filename to the API call (e.g. 'foo' instead of
'foo (1).iso'), which would then reject it because of the 'wrong'
extension.
Fix this by just using the battle proven trim from pve-common.
Fixes: 0fbcbc2
("fix #3990: multipart upload: rework to fix uploading small files")
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
c6702003c5
commit
a66b77d850
@ -46,7 +46,7 @@ use URI;
|
|||||||
|
|
||||||
use PVE::INotify;
|
use PVE::INotify;
|
||||||
use PVE::SafeSyslog;
|
use PVE::SafeSyslog;
|
||||||
use PVE::Tools;
|
use PVE::Tools qw(trim);
|
||||||
|
|
||||||
use PVE::APIServer::Formatter;
|
use PVE::APIServer::Formatter;
|
||||||
use PVE::APIServer::Utils;
|
use PVE::APIServer::Utils;
|
||||||
@ -1186,11 +1186,6 @@ my sub assert_form_disposition {
|
|||||||
sub file_upload_multipart {
|
sub file_upload_multipart {
|
||||||
my ($self, $reqstate, $auth, $method, $path, $rstate) = @_;
|
my ($self, $reqstate, $auth, $method, $path, $rstate) = @_;
|
||||||
|
|
||||||
my $trim = sub {
|
|
||||||
$_[0] =~ /\s*(\S+)/;
|
|
||||||
return $1;
|
|
||||||
};
|
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
my $boundary = $rstate->{boundary};
|
my $boundary = $rstate->{boundary};
|
||||||
my $hdl = $reqstate->{hdl};
|
my $hdl = $reqstate->{hdl};
|
||||||
@ -1210,7 +1205,7 @@ sub file_upload_multipart {
|
|||||||
my ($name) = @_;
|
my ($name) = @_;
|
||||||
if ($hdl->{rbuf} =~ s/^${delim_re}Content-Disposition: (.*?); name="$name"(.*?)($delim_re)/$3/s) {
|
if ($hdl->{rbuf} =~ s/^${delim_re}Content-Disposition: (.*?); name="$name"(.*?)($delim_re)/$3/s) {
|
||||||
assert_form_disposition($1);
|
assert_form_disposition($1);
|
||||||
$rstate->{params}->{$name} = $trim->($2);
|
$rstate->{params}->{$name} = trim($2);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1228,7 +1223,7 @@ sub file_upload_multipart {
|
|||||||
assert_form_disposition($1);
|
assert_form_disposition($1);
|
||||||
die "wrong field name '$2' for file upload, expected 'filename'" if $2 ne "filename";
|
die "wrong field name '$2' for file upload, expected 'filename'" if $2 ne "filename";
|
||||||
$rstate->{phase} = 2;
|
$rstate->{phase} = 2;
|
||||||
$rstate->{params}->{filename} = $trim->($3);
|
$rstate->{params}->{filename} = trim($3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user