Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent shell injection in search. #142

Merged
merged 2 commits into from
May 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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