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>
pull/28303/head
Jonas Meurer 5 years ago
parent 6844449465
commit 5f5bacde8f
No known key found for this signature in database
GPG Key ID: 5262E7FF491049FE
  1. 10
      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'];

Loading…
Cancel
Save