Return 500 when file or index is not readable to Dexter.

This commit is contained in:
Sam Greytalon 2023-11-16 09:02:05 -08:00
parent 453d6ab787
commit ea4332d207
1 changed files with 14 additions and 1 deletions

View File

@ -28,6 +28,7 @@ Readonly::Hash my %MEANING_OF_HTTP_CODE => (
'404' => 'File Not Found',
'409' => 'Conflict',
'413' => 'Payload Too Large',
'500' => 'Internal Server Error',
);
Readonly my $ROOT_DIRECTORY => 'public';
@ -119,7 +120,19 @@ helper render_index => sub ($c) {
my $url = $c->req->url;
my $user = $c->req->env->{REMOTE_USER};
my $path = $url->path;
if ( not -r $ROOT_DIRECTORY . $path->to_route ) {
$path->trailing_slash(0);
$path = $path->to_dir;
$url->path($path);
$c->render(template => 'error',
status => '500',
message => 'Dexter cannot read that file or index!');
return 0;
}
if ( not -d $ROOT_DIRECTORY . $path->to_route ) {
$path->trailing_slash(0);
$path = $path->to_dir;