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(),
));
})->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;

View File

@@ -85,7 +85,7 @@ class Routing
static $branchRegex = null;
if ($branchRegex === null) {
$branchRegex = '[\w-._\/]+';
$branchRegex = '(?!/|.*([/.]\.|//|@\{|\\\\))[^\040\177 ~^:?*\[]+(?<!\.lock|[/.])';
}
return $branchRegex;