Correct handling of filenames with spaces. Fixes #25

This commit is contained in:
Klaus Silveira
2012-05-31 01:46:36 -03:00
parent 7c9b4aca5e
commit d5051ca146
2 changed files with 5 additions and 5 deletions

View File

@@ -2,7 +2,7 @@
$app->get('{repo}/blob/{branch}/{file}/', function($repo, $branch, $file) use($app) { $app->get('{repo}/blob/{branch}/{file}/', function($repo, $branch, $file) use($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo); $repository = $app['git']->getRepository($app['git.repos'] . $repo);
$blob = $repository->getBlob("$branch:$file"); $blob = $repository->getBlob("$branch:'$file'");
$breadcrumbs = $app['utils']->getBreadcrumbs("$repo/tree/$branch/$file"); $breadcrumbs = $app['utils']->getBreadcrumbs("$repo/tree/$branch/$file");
$fileType = $app['utils']->getFileType($file); $fileType = $app['utils']->getFileType($file);
@@ -24,9 +24,9 @@ $app->get('{repo}/blob/{branch}/{file}/', function($repo, $branch, $file) use($a
$app->get('{repo}/raw/{branch}/{file}', function($repo, $branch, $file) use($app) { $app->get('{repo}/raw/{branch}/{file}', function($repo, $branch, $file) use($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo); $repository = $app['git']->getRepository($app['git.repos'] . $repo);
$blob = $repository->getBlob("$branch:$file")->output(); $blob = $repository->getBlob("$branch:'$file'")->output();
return new Symfony\Component\HttpFoundation\Response($blob, 200, array('Content-Type' => 'text/plain')); return new Symfony\Component\HttpFoundation\Response($blob, 200, array('Content-Type' => 'text/plain'));
})->assert('file', '.+') })->assert('file', '.+')
->assert('repo', '[\w-._]+') ->assert('repo', '[\w-._]+')
->assert('branch', '[\w-._]+'); ->assert('branch', '[\w-._]+');

View File

@@ -33,7 +33,7 @@ class Tree extends ScopeAware implements \RecursiveIterator
continue; continue;
} }
$files[] = preg_split("/[\s]+/", $line); $files[] = preg_split("/[\s]+/", $line, 5);
} }
foreach ($files as $file) { foreach ($files as $file) {
@@ -169,4 +169,4 @@ class Tree extends ScopeAware implements \RecursiveIterator
{ {
$this->name = $name; $this->name = $name;
} }
} }