Proper branch name validation, fixes #272

This commit is contained in:
Klaus Silveira
2013-03-29 00:26:16 -03:00
parent cf9aeaf773
commit 4eaebed43b
2 changed files with 4 additions and 4 deletions

View File

@@ -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;

View File

@@ -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;