mirror of
https://github.com/klaussilveira/gitlist.git
synced 2025-11-17 19:20:56 +01:00
Proper branch name validation, fixes #272
This commit is contained in:
@@ -68,13 +68,13 @@ class TreeController implements ControllerProviderInterface
|
|||||||
'tags' => $repository->getTags(),
|
'tags' => $repository->getTags(),
|
||||||
));
|
));
|
||||||
})->assert('repo', $app['util.routing']->getRepositoryRegex())
|
})->assert('repo', $app['util.routing']->getRepositoryRegex())
|
||||||
->assert('branch', '[\w-._\/]+')
|
->assert('branch', $app['util.routing']->getBranchRegex())
|
||||||
->bind('search');
|
->bind('search');
|
||||||
|
|
||||||
$route->get('{repo}/{branch}/', function ($repo, $branch) use ($app, $treeController) {
|
$route->get('{repo}/{branch}/', function ($repo, $branch) use ($app, $treeController) {
|
||||||
return $treeController($repo, $branch);
|
return $treeController($repo, $branch);
|
||||||
})->assert('repo', $app['util.routing']->getRepositoryRegex())
|
})->assert('repo', $app['util.routing']->getRepositoryRegex())
|
||||||
->assert('branch', '[\w-._\/]+')
|
->assert('branch', $app['util.routing']->getBranchRegex())
|
||||||
->bind('branch');
|
->bind('branch');
|
||||||
|
|
||||||
$route->get('{repo}/', function ($repo) use ($app, $treeController) {
|
$route->get('{repo}/', function ($repo) use ($app, $treeController) {
|
||||||
@@ -111,7 +111,7 @@ class TreeController implements ControllerProviderInterface
|
|||||||
));
|
));
|
||||||
})->assert('format', '(zip|tar)')
|
})->assert('format', '(zip|tar)')
|
||||||
->assert('repo', $app['util.routing']->getRepositoryRegex())
|
->assert('repo', $app['util.routing']->getRepositoryRegex())
|
||||||
->assert('branch', '[\w-._\/]+')
|
->assert('branch', $app['util.routing']->getBranchRegex())
|
||||||
->bind('archive');
|
->bind('archive');
|
||||||
|
|
||||||
return $route;
|
return $route;
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ class Routing
|
|||||||
static $branchRegex = null;
|
static $branchRegex = null;
|
||||||
|
|
||||||
if ($branchRegex === null) {
|
if ($branchRegex === null) {
|
||||||
$branchRegex = '[\w-._\/]+';
|
$branchRegex = '(?!/|.*([/.]\.|//|@\{|\\\\))[^\040\177 ~^:?*\[]+(?<!\.lock|[/.])';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $branchRegex;
|
return $branchRegex;
|
||||||
|
|||||||
Reference in New Issue
Block a user