diff options
| author | Appleman1234 <applemansigloo@gmail.com> | 2022-11-20 06:31:20 +1000 |
|---|---|---|
| committer | Appleman1234 <applemansigloo@gmail.com> | 2022-11-20 06:31:20 +1000 |
| commit | 1463d4ed9e7e7e1569f92e71582ef3ad805cf05a (patch) | |
| tree | 653d2d0e6583d93f3a4bd58d5abf7386670143ed /mod.php | |
| parent | 7f1fbadd971e3e09882896dcef394be5d33dfdcb (diff) | |
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
Diffstat (limited to 'mod.php')
| -rw-r--r-- | mod.php | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -183,7 +183,7 @@ foreach ($pages as $key => $callback) { if (is_string($callback) && preg_match('/^secure /', $callback)) $key .= '(/(?P<token>[a-f0-9]{8}))?'; $key = str_replace('\%b', '?P<board>' . 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']); |
