From 4b15fb1017093b321f0bd28f9412d63f30f29776 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Sat, 2 May 2020 16:27:02 +0200 Subject: [PATCH] support 404.html --- var/www/pages/index.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/var/www/pages/index.php b/var/www/pages/index.php index f074b63..2fae813 100644 --- a/var/www/pages/index.php +++ b/var/www/pages/index.php @@ -65,7 +65,13 @@ $command = "sh -c \"cd '$git_root' && /usr/bin/git show 'master:$file_url'\""; ## which seems wasteful, but it seems exec+echo cannot do raw binary output? Is this true? exec($command, $output, $retval); if ($retval != 0) { - send_response(404 , "no such file in repo: '" . htmlspecialchars($file_url) . "'"); + # check for a 404.html before we return an error. TODO: return 404 as response code + $file_url = "404.html"; + $command = "sh -c \"cd '$git_root' && /usr/bin/git show 'master:$file_url'\""; + exec($command, $output, $retval); + if ($retval != 0) { + send_response(404 , "no such file in repo: '" . htmlspecialchars($file_url) . "'"); + } } $mime_types = array(