From 1463d4ed9e7e7e1569f92e71582ef3ad805cf05a Mon Sep 17 00:00:00 2001 From: Appleman1234 Date: Sun, 20 Nov 2022 06:31:20 +1000 Subject: Fixing ability to call moderation functionality with PHP-8 by filtering out named parameters. as per https://github.com/vichan-devel/vichan/commit/d6ea8db5ef0af262fd8823c1bebb84efa06214a9 and https://github.com/vichan-devel/vichan/commit/401b5066915af3241fc5002e01b35e18ce0c8872 --- mod.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'mod.php') diff --git a/mod.php b/mod.php index 50be3471..4212a46b 100644 --- a/mod.php +++ b/mod.php @@ -183,7 +183,7 @@ foreach ($pages as $key => $callback) { if (is_string($callback) && preg_match('/^secure /', $callback)) $key .= '(/(?P[a-f0-9]{8}))?'; $key = str_replace('\%b', '?P' . sprintf(substr((string) $config['board_path'], 0, -1), $config['board_regex']), $key); - $new_pages[@$key[0] == '!' ? $key : '!^' . $key . '(?:&[^&=]+=[^&]*)*$!u'] = $callback; + $new_pages[(!empty($key) and $key[0] == '!') ? $key : '!^' . $key . '(?:&[^&=]+=[^&]*)*$!u'] = $callback; } $pages = $new_pages; @@ -228,6 +228,11 @@ foreach ($pages as $uri => $handler) { $debug['time']['parse_mod_req'] = '~' . round((microtime(true) - $parse_start_time) * 1000, 2) . 'ms'; } + if (is_array($matches)) { + // we don't want to call named parameters (PHP 8) + $matches = array_values($matches); + } + if (is_string($handler)) { if ($handler[0] == ':') { header('Location: ' . substr($handler, 1), true, $config['redirect_http']); -- cgit v1.3