From f8eb3c4b73b7cc139ab421517dc034d351ae00f5 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Thu, 7 Jan 2021 21:07:43 +0100 Subject: [PATCH] edit/page: save original request for commit message Minor code cleanup in not recreating the earlier name. --- edit/page/index.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/edit/page/index.php b/edit/page/index.php index d506e8f..194a25d 100644 --- a/edit/page/index.php +++ b/edit/page/index.php @@ -44,9 +44,10 @@ if ($_FILES) { if (!$_POST) abort("niets te doen", '405 post error'); -$filename = trim($Page->path, '/') ?: 'index'; -if (preg_match('{^\.}', $filename)) - abort("ongeldige bestandsnaam: $filename", '403 input error'); +$request = trim($Page->path, '/') ?: 'index'; +if (preg_match('{^\.}', $request)) + abort("ongeldige bestandsnaam: $request", '403 input error'); +$filename = $request; if (is_dir($filename) && !file_exists("$filename.html")) $filename .= '/index'; $filename .= '.html'; @@ -72,7 +73,7 @@ if (!file_put_contents($filename, $upload)) abort("fout bij schrijven van $filename", '500 save error'); if (is_writable('.git')) { - $gitmsg = preg_replace('/\.html$/', '', $filename).": edit from {$_SERVER['REMOTE_ADDR']}"; + $gitmsg = "$request: edit from {$_SERVER['REMOTE_ADDR']}"; $gitcmd = 'git'; $gitcmd .= ' -c user.name='.escapeshellarg($User->name ?: $User->login); $gitcmd .= ' -c user.email='.escapeshellarg($User->email ?: "{$User->login}@lijtweg.nl"); -- 2.30.0