diff --git a/src/GitList/Git/Repository.php b/src/GitList/Git/Repository.php
index 3d7a568..50d1f37 100644
--- a/src/GitList/Git/Repository.php
+++ b/src/GitList/Git/Repository.php
@@ -70,7 +70,8 @@ class Repository extends BaseRepository
public function searchCommitLog($query)
{
- $command = "log --grep=".escapeshellarg($query)." --pretty=format:\"- %H%h%T%P%an%ae%at%cn%ce%ct
\"";
+ $query = escapeshellarg($query);
+ $command = "log --grep={$query} --pretty=format:\"- %H%h%T%P%an%ae%at%cn%ce%ct
\"";
try {
$logs = $this->getPrettyFormat($command);
@@ -89,8 +90,10 @@ class Repository extends BaseRepository
public function searchTree($query, $branch)
{
+ $query = escapeshellarg($query);
+
try {
- $results = $this->getClient()->run($this, "grep -I --line-number ".escapeshellarg($query)." $branch");
+ $results = $this->getClient()->run($this, "grep -I --line-number {$query} $branch");
} catch (\RuntimeException $e) {
return false;
}