edit: replace executable check by filename validation
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 13 Sep 2017 18:03:32 +0000 (20:03 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 18 Sep 2017 18:21:28 +0000 (20:21 +0200)
No more distinction in php files; prefer a-x.

auth.inc.php [changed mode: 0755->0644]
edit.php [changed mode: 0755->0644]
foot.inc.php [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 1856336..cf9b6c0
--- a/edit.php
+++ b/edit.php
@@ -14,9 +14,9 @@ if (!isset($_SERVER['PATH_INFO']) or strlen($_SERVER['PATH_INFO']) <= 1)
        abort('409 input error', "geen bestand aangeleverd");
 
 $filename = ltrim($Args, '/').'.html';
-if (file_exists($filename) and !is_writable($filename))
+if (!preg_match('{^(?:[/a-z0-9-])+\.html$}', $filename))
        abort('403 input error', "ongeldige bestandsnaam: $filename");
-if (is_executable($filename))
+if (file_exists($filename) and !is_writable($filename))
        abort('403 input error', "onwijzigbaar bestand: $filename");
 
 if (!isset($_POST['body']))
old mode 100755 (executable)
new mode 100644 (file)