From 453d6ab787c91f3fa772f7b0a165cf12f1d5f860 Mon Sep 17 00:00:00 2001 From: Sam Talonborn Date: Thu, 16 Nov 2023 08:49:12 -0800 Subject: [PATCH] Add proper 404 page. --- app/dexter.pl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/dexter.pl b/app/dexter.pl index 0198af5..efdb21a 100755 --- a/app/dexter.pl +++ b/app/dexter.pl @@ -120,6 +120,18 @@ helper render_index => sub ($c) { my $user = $c->req->env->{REMOTE_USER}; my $path = $url->path; + if ( not -d $ROOT_DIRECTORY . $path->to_route ) { + $path->trailing_slash(0); + $path = $path->to_dir; + $url->path($path); + + $c->render(template => 'error', + status => '404', + message => 'That file does not exist!'); + + return 0; + } + if ( not user_has_permission_on_path($user, 'READ', $path) ) { $c->render(template => 'error', status => '403',