mirror of
https://github.com/nextcloud/server.git
synced 2026-04-27 09:08:22 -04:00
fix(RouteParser): bail out if method name contains hashtag
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
parent
63ba61487b
commit
e4ed062d68
2 changed files with 10 additions and 1 deletions
|
|
@ -76,7 +76,7 @@ class RouteParser {
|
|||
$url = $root . '/' . ltrim($route['url'], '/');
|
||||
$verb = strtoupper($route['verb'] ?? 'GET');
|
||||
|
||||
$split = explode('#', $name, 2);
|
||||
$split = explode('#', $name, 3);
|
||||
if (count($split) !== 2) {
|
||||
throw new \UnexpectedValueException('Invalid route name: use the format foo#bar to reference FooController::bar');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,6 +142,15 @@ class RouteParserTest extends \Test\TestCase {
|
|||
$this->parser->parseDefaultRoutes($routes, 'app1');
|
||||
}
|
||||
|
||||
public function testParseRoutesInvalidName2(): void {
|
||||
$routes = ['routes' => [
|
||||
['name' => 'folders#open#action', 'url' => '/{folderId}/open', 'verb' => 'GET']
|
||||
]];
|
||||
|
||||
$this->expectException(\UnexpectedValueException::class);
|
||||
$this->parser->parseDefaultRoutes($routes, 'app1');
|
||||
}
|
||||
|
||||
public function testParseRoutesEmpty(): void {
|
||||
$routes = ['routes' => []];
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue