Skip to content

Commit

Permalink
Add validation to Branch name before switching
Browse files Browse the repository at this point in the history
  • Loading branch information
ghormann committed Jun 27, 2021
1 parent a10c8a3 commit 19c55e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions scripts/git_branch
Expand Up @@ -15,6 +15,12 @@ teeOutput

echo "$0 running to switch branches to $1"

CNT=`cd ${FPPDIR} && git show-ref | grep "refs/remotes/origin" | grep -i $1 | wc -l`
if [ $CNT -eq 0 ]; then
echo "Invalid Branch Name: $1"
exit 1
fi

echo "Stopping fppd"
${SUDO} ${FPPDIR}/scripts/fppd_stop

Expand Down
2 changes: 1 addition & 1 deletion www/changebranch.php
Expand Up @@ -19,7 +19,7 @@
<?php
echo "==================================================================================\n";

$branch = escapeshellcmd($_GET['branch']);
$branch = escapeshellcmd(htmlspecialchars($_GET['branch']));
$command = "sudo /opt/fpp/scripts/git_branch " . $branch . " 2>&1";

echo "Command: $command\n";
Expand Down

0 comments on commit 19c55e2

Please sign in to comment.