Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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 <[email protected]>
  • Loading branch information
mejo- committed Aug 16, 2021
commit 5f5bacde8f6f65eeaba0d1b86eb134b5527c0d54
10 changes: 9 additions & 1 deletion core/Controller/UnifiedSearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,17 @@ protected function getRouteInformation(string $url): array {

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'];
Expand Down