diff options
author | Jonas Meurer <jonas@freesources.org> | 2021-08-03 17:27:48 +0200 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2021-08-16 13:11:59 +0000 |
commit | 57e20ed566136581756a80e07995bb25f72bbcf6 (patch) | |
tree | 136ae8cc3ea11cf3492f510a43f1a7428de37803 | |
parent | e9fc8e1dcbdda70da77c23668b99908754602988 (diff) | |
download | nextcloud-server-57e20ed566136581756a80e07995bb25f72bbcf6.tar.gz nextcloud-server-57e20ed566136581756a80e07995bb25f72bbcf6.zip |
UnifiedSearchController: strip webroot from URL before finding a route
This should fix route matching in UnifiedSearchController on setups with
Nextcloud in a subfolder (webroot).
Fixes: #24144
Signed-off-by: Jonas Meurer <jonas@freesources.org>
-rw-r--r-- | core/Controller/UnifiedSearchController.php | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/core/Controller/UnifiedSearchController.php b/core/Controller/UnifiedSearchController.php index 93fbb323ee5..3836c9a6d41 100644 --- a/core/Controller/UnifiedSearchController.php +++ b/core/Controller/UnifiedSearchController.php @@ -123,9 +123,17 @@ class UnifiedSearchController extends OCSController { if ($url !== '') { $urlParts = parse_url($url); + $urlPath = $urlParts['path']; + + // Optionally strip webroot from URL. Required for route matching on setups + // with Nextcloud in a webserver subfolder (webroot). + $webroot = \OC::$WEBROOT; + if ($webroot !== '' && substr($urlPath, 0, strlen($webroot)) === $webroot) { + $urlPath = substr($urlPath, strlen($webroot)); + } try { - $parameters = $this->router->findMatchingRoute($urlParts['path']); + $parameters = $this->router->findMatchingRoute($urlPath); // contacts.PageController.index => contacts.Page.index $route = $parameters['caller']; |