Skip to content

Commit

Permalink
Merge pull request #202 from creative-commoners/pulls/2.0/escape-file…
Browse files Browse the repository at this point in the history
…-execution

FIX Escape file path before loading file from filesystem
  • Loading branch information
Damian Mooyman authored Dec 7, 2017
2 parents 82a8a4b + 8efedf3 commit bcf2ac9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion code/model/DMSDocument_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,15 @@ public function index(SS_HTTPRequest $request)
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $path);
} elseif (is_executable($fileBin)) {
$path = escapeshellarg($path);
// try to use the system tool
$mime = `$fileBin -i -b $path`;
$mime = explode(';', $mime);
$mime = trim($mime[0]);
} else {
// make do with what we have
$ext = $doc->getExtension();
if ($ext =='pdf') {
if ($ext == 'pdf') {
$mime = 'application/pdf';
} elseif ($ext == 'html' || $ext =='htm') {
$mime = 'text/html';
Expand Down

0 comments on commit bcf2ac9

Please sign in to comment.