Add a check for if the file being accessed is a directory. This improves the error relayed to the user, which - when mistakenly trying to access a directory instead of a file - would return:
`unable to detect content type at /usr/share/perl5/PVE/APIServer/AnyEvent.pm line 499.` Signed-off-by: Nicolas Frey <[email protected]> --- src/PVE/APIServer/AnyEvent.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/PVE/APIServer/AnyEvent.pm b/src/PVE/APIServer/AnyEvent.pm index 36dee02..3a7fa1b 100644 --- a/src/PVE/APIServer/AnyEvent.pm +++ b/src/PVE/APIServer/AnyEvent.pm @@ -1252,6 +1252,9 @@ sub handle_request { my ($subdir, $file) = ($1, $2); if (my $dir = $self->{dirs}->{$subdir}) { my $filename = "$dir$file"; + if (-d $filename) { + die "unable to open file '$filename' because it is a directory\n"; + } my $fh = IO::File->new($filename) || die "unable to open file '$filename' - $!\n"; send_file_start($self, $reqstate, { path => $filename }); -- 2.47.3 _______________________________________________ pve-devel mailing list [email protected] https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
