aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/route
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-09-22 10:59:12 +0200
committerJoas Schilling <nickvergessen@gmx.de>2014-09-22 11:22:33 +0200
commit71bec60b929e28c10fee9ec71920aa7f33cbe735 (patch)
tree1981098ef35fc046603874364de952cdbc4da287 /lib/private/route
parent637cff68ac2944d6029eb015640bbbd0e686641b (diff)
downloadnextcloud-server-71bec60b929e28c10fee9ec71920aa7f33cbe735.tar.gz
nextcloud-server-71bec60b929e28c10fee9ec71920aa7f33cbe735.zip
Also match routes without trailing slash
Fix #11209
Diffstat (limited to 'lib/private/route')
-rw-r--r--lib/private/route/router.php21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/private/route/router.php b/lib/private/route/router.php
index 9c973d7ac6a..aa3d05dcb85 100644
--- a/lib/private/route/router.php
+++ b/lib/private/route/router.php
@@ -13,6 +13,7 @@ use Symfony\Component\Routing\Matcher\UrlMatcher;
use Symfony\Component\Routing\Generator\UrlGenerator;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\RouteCollection;
+use Symfony\Component\Routing\Exception\ResourceNotFoundException;
class Router implements IRouter {
/**
@@ -215,8 +216,26 @@ class Router implements IRouter {
} else {
$this->loadRoutes();
}
+
$matcher = new UrlMatcher($this->root, $this->context);
- $parameters = $matcher->match($url);
+ try {
+ $parameters = $matcher->match($url);
+ } catch (ResourceNotFoundException $e) {
+ if (substr($url, -1) !== '/') {
+ // We allow links to apps/files? for backwards compatibility reasons
+ // However, since Symfony does not allow empty route names, the route
+ // we need to match is '/', so we need to append the '/' here.
+ try {
+ $parameters = $matcher->match($url . '/');
+ } catch (ResourceNotFoundException $newException) {
+ // If we still didn't match a route, we throw the original exception
+ throw $e;
+ }
+ } else {
+ throw $e;
+ }
+ }
+
if (isset($parameters['action'])) {
$action = $parameters['action'];
if (!is_callable($action)) {