mirror of
https://github.com/klaussilveira/gitlist.git
synced 2025-11-18 03:30:55 +01:00
Fix escaping issue with dashes, hashes.
This commit is contained in:
@@ -106,36 +106,24 @@ class Routing
|
||||
public function getRepositoryRegex()
|
||||
{
|
||||
static $regex = null;
|
||||
|
||||
if ($regex === null) {
|
||||
$isWindows = $this->isWindows();
|
||||
$quotedPaths = array_map(
|
||||
function ($repo) use ($isWindows) {
|
||||
$repoName = preg_quote($repo['name']);
|
||||
|
||||
if ($isWindows) {
|
||||
$repoName = str_replace('\\', '\\\\', $repoName);
|
||||
}
|
||||
|
||||
return $repoName;
|
||||
function ($repo) {
|
||||
return preg_quote($repo['name'], '#');
|
||||
},
|
||||
$this->app['git']->getRepositories($this->app['git.repos'])
|
||||
);
|
||||
|
||||
usort(
|
||||
$quotedPaths,
|
||||
function ($a, $b) {
|
||||
return strlen($b) - strlen($a);
|
||||
}
|
||||
);
|
||||
|
||||
$regex = implode('|', $quotedPaths);
|
||||
}
|
||||
|
||||
return $regex;
|
||||
}
|
||||
|
||||
|
||||
public function isWindows()
|
||||
{
|
||||
switch (PHP_OS) {
|
||||
|
||||
Reference in New Issue
Block a user