Skip to content

Commit

Permalink
Merge pull request #142 from ams-tschoening/search_shell_injection
Browse files Browse the repository at this point in the history
Prevent shell injection in search.
  • Loading branch information
k10blogger committed May 12, 2021
2 parents 94aa3eb + b8c09bb commit 88fce56
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions include/svnlook.php
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ function listFileContents($path, $rev = 0, $peg = '') {
}

// }}}

// {{{ listReadmeContents
//
// Parse the README.md file
Expand Down Expand Up @@ -895,7 +895,7 @@ function listReadmeContents($path, $rev = 0, $peg = '') {
}

echo('<div id="wrap">');
while (!feof($result))
while (!feof($result))
{
$line = fgets($result, 1024);
echo $mdParser->text($line);
Expand Down Expand Up @@ -1112,19 +1112,18 @@ function getList($path, $rev = 0, $peg = '') {

// {{{ getListSearch

function getListSearch($path,$searchstring='', $rev = 0, $peg = '') {
function getListSearch($path, $term = '', $rev = 0, $peg = '') {
global $config, $curList;

// Since directories returned by svn log don't have trailing slashes (:-(), we need to remove
// the trailing slash from the path for comparison purposes

if ($path[strlen($path) - 1] == '/' && $path != '/') {
// Since directories returned by "svn log" don't have trailing slashes (:-(), we need to
// remove the trailing slash from the path for comparison purposes.
if (($path[strlen($path) - 1] == '/') && ($path != '/')) {
$path = substr($path, 0, -1);
}

$curList = new SVNList;
$curList->entries = array();
$curList->path = $path;
$curList = new SVNList;
$curList->entries = array();
$curList->path = $path;

// Get the list info

Expand All @@ -1134,7 +1133,9 @@ function getListSearch($path,$searchstring='', $rev = 0, $peg = '') {
$rev = $headlog->entries[0]->rev;
}

$cmd = $this->svnCommandString('list -R --search '. '"'.$searchstring.'"'.' --xml', $path, $rev, $peg);
$term = escapeshellarg($term);
$cmd = 'list -R --search ' . $term . ' --xml';
$cmd = $this->svnCommandString($cmd, $path, $rev, $peg);
$this->_xmlParseCmdOutput($cmd, 'listStartElement', 'listEndElement', 'listCharacterData');

return $curList;
Expand Down

0 comments on commit 88fce56

Please sign in to comment.