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