From 06f194408fcd4b8dc1796f66071136a3d9629ce0 Mon Sep 17 00:00:00 2001 From: michalsn Date: Fri, 27 Jun 2025 09:42:15 +0200 Subject: [PATCH] fix: support for multibyte folder names when the app is served from a subfolder --- system/HTTP/SiteURIFactory.php | 3 ++- .../HTTP/SiteURIFactoryDetectRoutePathTest.php | 12 ++++++++++++ user_guide_src/source/changelogs/v4.6.2.rst | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/system/HTTP/SiteURIFactory.php b/system/HTTP/SiteURIFactory.php index 2c94f23f4678..483c3ded5779 100644 --- a/system/HTTP/SiteURIFactory.php +++ b/system/HTTP/SiteURIFactory.php @@ -132,7 +132,8 @@ private function parseRequestURI(): string && pathinfo($this->superglobals->server('SCRIPT_NAME'), PATHINFO_EXTENSION) === 'php' ) { // Compare each segment, dropping them until there is no match - $segments = $keep = explode('/', $path); + $segments = explode('/', rawurldecode($path)); + $keep = explode('/', $path); foreach (explode('/', $this->superglobals->server('SCRIPT_NAME')) as $i => $segment) { // If these segments are not the same then we're done diff --git a/tests/system/HTTP/SiteURIFactoryDetectRoutePathTest.php b/tests/system/HTTP/SiteURIFactoryDetectRoutePathTest.php index fc717b78176f..cbd309dffa7c 100644 --- a/tests/system/HTTP/SiteURIFactoryDetectRoutePathTest.php +++ b/tests/system/HTTP/SiteURIFactoryDetectRoutePathTest.php @@ -402,6 +402,18 @@ public static function provideRequestURIRewrite(): iterable 'indexPage' => 'index.php', 'expected' => 'myindex.php/route', ], + 'multibyte_characters' => [ + 'requestUri' => '/%ED%85%8C%EC%8A%A4%ED%8A%B81/index.php/route', + 'scriptName' => '/테스트1/public/index.php', + 'indexPage' => 'index.php', + 'expected' => 'route', + ], + 'multibyte_characters_with_nested_subfolder' => [ + 'requestUri' => '/%D0%BF%D1%80%D0%BE%D0%B5%D0%BA%D1%82/%D1%82%D0%B5%D1%81%D1%821/index.php/route', + 'scriptName' => '/проект/тест1/public/index.php', + 'indexPage' => 'index.php', + 'expected' => 'route', + ], ]; } } diff --git a/user_guide_src/source/changelogs/v4.6.2.rst b/user_guide_src/source/changelogs/v4.6.2.rst index e9d7a65eb99d..360e592b680d 100644 --- a/user_guide_src/source/changelogs/v4.6.2.rst +++ b/user_guide_src/source/changelogs/v4.6.2.rst @@ -42,6 +42,7 @@ Bugs Fixed - **Security:** Fixed a bug where the ``sanitize_filename()`` function from the Security helper would throw an error when used in CLI requests. - **Session:** Fixed a bug where using the ``DatabaseHandler`` with an unsupported database driver (such as ``SQLSRV``, ``OCI8``, or ``SQLite3``) did not throw an appropriate error. - **SiteURI:** Fixed a bug in ``SiteURIFactory::parseRequestURI()`` where serving the app from a subfolder using ``mod_rewrite`` while preserving the ``index.php`` file would cause incorrect route path detection. +- **SiteURI:** Fixed a bug in ``SiteURIFactory::parseRequestURI()`` where folder names containing multibyte (non-ASCII) characters were not correctly resolved when the application was served from a subfolder. - **URI:** Fixed a bug in ``URI::getAuthority()`` where schemes without defined default ports (like ``rtsp://``) would cause issues due to missing array key handling. See the repo's