diff --git a/system/Filters/Filters.php b/system/Filters/Filters.php index fa27dc7b518d..963638bdfb8f 100644 --- a/system/Filters/Filters.php +++ b/system/Filters/Filters.php @@ -376,6 +376,8 @@ private function setToolbarToLast(array $filters, bool $remove = false): array * * @param string|null $uri URI path relative to baseURL (all lowercase) * + * @TODO We don't need to accept null as $uri. + * * @return Filters */ public function initialize(?string $uri = null) @@ -385,7 +387,7 @@ public function initialize(?string $uri = null) } // Decode URL-encoded string - $uri = urldecode($uri); + $uri = urldecode($uri ?? ''); $oldFilterOrder = config(Feature::class)->oldFilterOrder ?? false; if ($oldFilterOrder) { diff --git a/tests/system/Commands/Utilities/ConfigCheckTest.php b/tests/system/Commands/Utilities/ConfigCheckTest.php index 00066e472187..9d2c5fdfd3d3 100644 --- a/tests/system/Commands/Utilities/ConfigCheckTest.php +++ b/tests/system/Commands/Utilities/ConfigCheckTest.php @@ -96,6 +96,7 @@ public function testGetKintD() public 'allowedHostnames' -> array (0) [] public 'indexPage' -> string (9) "index.php" public 'uriProtocol' -> string (11) "REQUEST_URI" + public 'permittedURIChars' -> string (14) "a-z 0-9~%.:_\-" public 'defaultLocale' -> string (2) "en" public 'negotiateLocale' -> boolean false public 'supportedLocales' -> array (1) [ @@ -150,6 +151,8 @@ public function testGetVarDump() string(9) "index.php" public string $uriProtocol => string(11) "REQUEST_URI" + public string $permittedURIChars => + string(14) "a-z 0-9~%.:_\-" public string $defaultLocale => string(2) "en" public bool $negotiateLocale => @@ -192,6 +195,8 @@ public function testGetVarDump() string(9) "index.php" ["uriProtocol"]=> string(11) "REQUEST_URI" + ["permittedURIChars"]=> + string(14) "a-z 0-9~%.:_\-" ["defaultLocale"]=> string(2) "en" ["negotiateLocale"]=> diff --git a/tests/system/Filters/FiltersTest.php b/tests/system/Filters/FiltersTest.php index ef8d2a9b0cac..7905cfefdae6 100644 --- a/tests/system/Filters/FiltersTest.php +++ b/tests/system/Filters/FiltersTest.php @@ -1097,8 +1097,8 @@ public function testMatchesURIWithUnicode(): void 'frak', ], 'after' => [ - 'baz', 'frak', + 'baz', ], ]; $this->assertSame($expected, $filters->initialize($uri)->getFilters());