Skip to content

Commit

Permalink
Fix upload bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ajnyga committed Feb 8, 2021
1 parent 4dcce92 commit c36afac
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions AllowedUploadsPlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,25 @@ function manage($args, $request) {
* Check the uploaded file in wizard
*/
function checkUploadWizard($hookName, $params) {
$errors =& $params[0];
$props = $params[2];
$locale = $params[4];
$request = Application::getRequest();
$context = $request->getContext();

$fileName = $props['name'][$locale];
$tmp = explode('.',$fileName);
$extension = strtolower(end($tmp));

$allowedExtensions = $this->getSetting($context->getId(), 'allowedExtensions');

if ($allowedExtensions){
$allowedExtensionsArray = array_filter(array_map('trim', explode(';', $allowedExtensions )), 'strlen');
if (!in_array($extension, $allowedExtensionsArray)){
$errors['allowedExtensions'][$locale] = __('plugins.generic.allowedUploads.error', array('allowedExtensions' => $allowedExtensions));

if ($params[1] == 'add'){
$errors =& $params[0];
$props = $params[2];
$locale = $params[4];
$request = Application::getRequest();
$context = $request->getContext();

$fileName = $props['name'][$locale];
$tmp = explode('.',$fileName);
$extension = strtolower(end($tmp));

$allowedExtensions = $this->getSetting($context->getId(), 'allowedExtensions');

if ($allowedExtensions){
$allowedExtensionsArray = array_filter(array_map('trim', explode(';', $allowedExtensions )), 'strlen');
if (!in_array($extension, $allowedExtensionsArray)){
$errors['allowedExtensions'] = __('plugins.generic.allowedUploads.error', array('allowedExtensions' => $allowedExtensions));
}
}
}
}
Expand Down

0 comments on commit c36afac

Please sign in to comment.