Skip to content

Commit

Permalink
UnifiedSearchController: strip webroot from URL before finding a route
Browse files Browse the repository at this point in the history
This should fix route matching in UnifiedSearchController on setups with
Nextcloud in a subfolder (webroot).

Fixes: #24144
Signed-off-by: Jonas Meurer <[email protected]>
  • Loading branch information
mejo- committed Aug 3, 2021
1 parent f01289f commit 5e85577
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion core/Controller/UnifiedSearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,16 @@ protected function getRouteInformation(string $url): array {

if ($url !== '') {
$urlParts = parse_url($url);
$urlPath = $urlParts['path'];

// Optionally strip webroot from URL
$webroot = \OC::$WEBROOT;
if ($webroot !== '' && substr($urlPath, 0, strlen($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'];
Expand Down

0 comments on commit 5e85577

Please sign in to comment.