mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 08:44:07 -04:00
fix(Routing): Only use lowercase names for registering and matching routes
Signed-off-by: provokateurin <kate@provokateurin.de>
This commit is contained in:
parent
ce91b2dc98
commit
66e7056c5e
3 changed files with 36 additions and 17 deletions
|
|
@ -136,7 +136,13 @@ class RouteConfig {
|
|||
$controllerName = $this->buildControllerName($controller);
|
||||
$actionName = $this->buildActionName($action);
|
||||
|
||||
$routeName = $routeNamePrefix . $this->appName . '.' . $controller . '.' . $action . $postfix;
|
||||
/*
|
||||
* The route name has to be lowercase, for symfony to match it correctly.
|
||||
* This is required because smyfony allows mixed casing for controller names in the routes.
|
||||
* To avoid breaking all the existing route names, registering and matching will only use the lowercase names.
|
||||
* This is also safe on the PHP side because class and method names collide regardless of the casing.
|
||||
*/
|
||||
$routeName = strtolower($routeNamePrefix . $this->appName . '.' . $controller . '.' . $action . $postfix);
|
||||
|
||||
$router = $this->router->create($routeName, $url)
|
||||
->method($verb);
|
||||
|
|
|
|||
|
|
@ -100,7 +100,13 @@ class RouteParser {
|
|||
$controllerName = $this->buildControllerName($controller);
|
||||
$actionName = $this->buildActionName($action);
|
||||
|
||||
$routeName = $routeNamePrefix . $appName . '.' . $controller . '.' . $action . $postfix;
|
||||
/*
|
||||
* The route name has to be lowercase, for symfony to match it correctly.
|
||||
* This is required because smyfony allows mixed casing for controller names in the routes.
|
||||
* To avoid breaking all the existing route names, registering and matching will only use the lowercase names.
|
||||
* This is also safe on the PHP side because class and method names collide regardless of the casing.
|
||||
*/
|
||||
$routeName = strtolower($routeNamePrefix . $appName . '.' . $controller . '.' . $action . $postfix);
|
||||
|
||||
$routeObject = new Route($url);
|
||||
$routeObject->method($verb);
|
||||
|
|
|
|||
|
|
@ -360,6 +360,13 @@ class Router implements IRouter {
|
|||
if ($absolute === false) {
|
||||
$referenceType = UrlGenerator::ABSOLUTE_PATH;
|
||||
}
|
||||
/*
|
||||
* The route name has to be lowercase, for symfony to match it correctly.
|
||||
* This is required because smyfony allows mixed casing for controller names in the routes.
|
||||
* To avoid breaking all the existing route names, registering and matching will only use the lowercase names.
|
||||
* This is also safe on the PHP side because class and method names collide regardless of the casing.
|
||||
*/
|
||||
$name = strtolower($name);
|
||||
$name = $this->fixLegacyRootName($name);
|
||||
if (str_contains($name, '.')) {
|
||||
[$appName, $other] = explode('.', $name, 3);
|
||||
|
|
@ -385,29 +392,29 @@ class Router implements IRouter {
|
|||
}
|
||||
|
||||
protected function fixLegacyRootName(string $routeName): string {
|
||||
if ($routeName === 'files.viewcontroller.showFile') {
|
||||
return 'files.View.showFile';
|
||||
if ($routeName === 'files.viewcontroller.showfile') {
|
||||
return 'files.view.showfile';
|
||||
}
|
||||
if ($routeName === 'files_sharing.sharecontroller.showShare') {
|
||||
return 'files_sharing.Share.showShare';
|
||||
if ($routeName === 'files_sharing.sharecontroller.showshare') {
|
||||
return 'files_sharing.share.showshare';
|
||||
}
|
||||
if ($routeName === 'files_sharing.sharecontroller.showAuthenticate') {
|
||||
return 'files_sharing.Share.showAuthenticate';
|
||||
if ($routeName === 'files_sharing.sharecontroller.showauthenticate') {
|
||||
return 'files_sharing.share.showauthenticate';
|
||||
}
|
||||
if ($routeName === 'files_sharing.sharecontroller.authenticate') {
|
||||
return 'files_sharing.Share.authenticate';
|
||||
return 'files_sharing.share.authenticate';
|
||||
}
|
||||
if ($routeName === 'files_sharing.sharecontroller.downloadShare') {
|
||||
return 'files_sharing.Share.downloadShare';
|
||||
if ($routeName === 'files_sharing.sharecontroller.downloadshare') {
|
||||
return 'files_sharing.share.downloadshare';
|
||||
}
|
||||
if ($routeName === 'files_sharing.publicpreview.directLink') {
|
||||
return 'files_sharing.PublicPreview.directLink';
|
||||
if ($routeName === 'files_sharing.publicpreview.directlink') {
|
||||
return 'files_sharing.publicpreview.directlink';
|
||||
}
|
||||
if ($routeName === 'cloud_federation_api.requesthandlercontroller.addShare') {
|
||||
return 'cloud_federation_api.RequestHandler.addShare';
|
||||
if ($routeName === 'cloud_federation_api.requesthandlercontroller.addshare') {
|
||||
return 'cloud_federation_api.requesthandler.addshare';
|
||||
}
|
||||
if ($routeName === 'cloud_federation_api.requesthandlercontroller.receiveNotification') {
|
||||
return 'cloud_federation_api.RequestHandler.receiveNotification';
|
||||
if ($routeName === 'cloud_federation_api.requesthandlercontroller.receivenotification') {
|
||||
return 'cloud_federation_api.requesthandler.receivenotification';
|
||||
}
|
||||
return $routeName;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue