-
-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
…the mime-type supplied and use mime-type from db if supplied with an fid and eid Switch to different libary that is php5.6 compatable
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,22 +68,22 @@ public function run() { | |
$mimeType = ''; | ||
$path = CRM_Core_Config::singleton()->customFileUploadDir . $fileName; | ||
} | ||
$passedInMimeType = CRM_Utils_Request::retrieveValue('mime-type', 'String', $mimeType, FALSE); | ||
|
||
if (!$path) { | ||
CRM_Core_Error::statusBounce('Could not retrieve the file'); | ||
} | ||
if (!empty($mimeType) && !empty($passedInMimeType)) { | ||
if ($passedInMimeType != $mimeType) { | ||
throw new CRM_Core_Exception("Supplied Mime Type does not match file Mime Type"); | ||
|
||
if (empty($mimeType)) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
seamuslee001
Author
Contributor
|
||
$passedInMimeType = CRM_Utils_Request::retrieveValue('mime-type', 'String', $mimeType, FALSE); | ||
if (!in_array($passedInMimeType, explode(',', Civi::settings()->get('requestableMimeTypes')))) { | ||
throw new CRM_Core_Exception("Supplied mime-type is not accepted"); | ||
} | ||
} | ||
elseif (!empty($passedInMimeType)) { | ||
$testMimeType = CRM_Utils_File::getMimeType($path); | ||
if ($testMimeType != $passedInMimeType) { | ||
throw new CRM_Core_Exception("Supplied Mime Type does not match file Mime Type"); | ||
$extension = CRM_Utils_File::getExtensionFromPath($path); | ||
$candidateExtensions = CRM_Utils_File::getAcceptableExtensionsForMimeType($passedInMimeType); | ||
if (!in_array($extension, $candidateExtensions)) { | ||
throw new CRM_Core_Exception("Supplied mime-type does not match file extension"); | ||
} | ||
// Now that we have ensured that the mime-type matches to what we believe is the mime-type of the file | ||
// Now that we have validated mime-type supplied as much as possible lets now set the MimeType variable/ | ||
$mimeType = $passedInMimeType; | ||
} | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
@seamuslee001 I've been getting Civi errors that I think are related to this line. Shouldn't the logic on this
if
statement be reversed?