valid_page check was wrong again, it is supposed to check if the page name contains any invalid chars and that the .md file exists

This commit is contained in:
Alexander 2024-10-04 23:37:00 +00:00
parent b18575abb8
commit e25acc1658

View file

@ -11,7 +11,7 @@ $parser = wiki::factory(true);
$page = $_GET['page'];
$page = preg_replace(',/$,', '', $page);
$page = preg_replace(',/,', '-', $page);
$valid_page = (preg_match("/[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-]*/", $page) && file_exists("pages/{$page}.md"));
$valid_page = (!preg_match("/[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-]/", $page) && file_exists("pages/{$page}.md"));
if ($page !== "" && !$valid_page) {
http_response_code(404);
echo "This wiki page doesn't exist, you'll be redirected to the homepage.\n";