mirror of
https://github.com/silverstripe/silverstripe-dms
synced 2024-10-22 14:05:56 +02:00
Merge pull request #202 from creative-commoners/pulls/2.0/escape-file-execution
FIX Escape file path before loading file from filesystem
This commit is contained in:
commit
bcf2ac9757
@ -82,6 +82,7 @@ class DMSDocument_Controller extends Controller
|
||||
$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);
|
||||
@ -89,7 +90,7 @@ class DMSDocument_Controller extends Controller
|
||||
} 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';
|
||||
|
Loading…
Reference in New Issue
Block a user