Skip to content

Commit b687560

Browse files
committed
Update Git.php
User input validation. Some minor fixes.
1 parent 0d1a996 commit b687560

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Git.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ public function clean($dirs = false, $force = false) {
465465
* @return string
466466
*/
467467
public function create_branch($branch) {
468-
return $this->run("branch $branch");
468+
return $this->run("branch " . escapeshellarg($branch));
469469
}
470470

471471
/**
@@ -549,7 +549,7 @@ public function active_branch($keep_asterisk = false) {
549549
* @return string
550550
*/
551551
public function checkout($branch) {
552-
return $this->run("checkout $branch");
552+
return $this->run("checkout " . escapeshellarg($branch));
553553
}
554554

555555

@@ -563,7 +563,7 @@ public function checkout($branch) {
563563
* @return string
564564
*/
565565
public function merge($branch) {
566-
return $this->run("merge $branch --no-ff");
566+
return $this->run("merge " . escapeshellarg($branch) . " --no-ff");
567567
}
568568

569569

@@ -587,7 +587,7 @@ public function fetch() {
587587
* @return string
588588
*/
589589
public function add_tag($tag, $message = null) {
590-
if ($message === null) {
590+
if (is_null($message)) {
591591
$message = $tag;
592592
}
593593
return $this->run("tag -a $tag -m " . escapeshellarg($message));
@@ -606,7 +606,7 @@ public function list_tags($pattern = null) {
606606
$tagArray = explode("\n", $this->run("tag -l $pattern"));
607607
foreach ($tagArray as $i => &$tag) {
608608
$tag = trim($tag);
609-
if ($tag == '') {
609+
if (empty($tag)) {
610610
unset($tagArray[$i]);
611611
}
612612
}

0 commit comments

Comments
 (0)