From 57e20ed566136581756a80e07995bb25f72bbcf6 Mon Sep 17 00:00:00 2001 From: Jonas Meurer Date: Tue, 3 Aug 2021 17:27:48 +0200 Subject: 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 --- core/Controller/UnifiedSearchController.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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']; -- cgit v1.2.3