diff --git a/src/GitList/Util/Repository.php b/src/GitList/Util/Repository.php index 80d783d..5659125 100644 --- a/src/GitList/Util/Repository.php +++ b/src/GitList/Util/Repository.php @@ -199,7 +199,7 @@ class Repository // Otherwise, attempt to detect the ref using a list of the project's branches and tags $valid_refs = array_merge((array) $repository->getBranches(), (array) $repository->getTags()); foreach ($valid_refs as $k => $v) { - if (!preg_match("#{$v}/#", $input)) { + if (!preg_match(sprintf("#^%s/#", preg_quote($v, '#')), $input)) { unset($valid_refs[$k]); } } @@ -207,7 +207,7 @@ class Repository // No exact ref match, so just try our best if (count($valid_refs) > 1) { preg_match('/([^\/]+)(.*)/', $input, $matches); - $branch = preg_replace('/^\/|\/$/', '', $matches[0]); + $branch = preg_replace('/^\/|\/$/', '', $matches[1]); } else { // Extract branch name $branch = array_shift($valid_refs);