Skip to content

Commit

Permalink
Check if extension list is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
ajnyga committed Feb 24, 2018
1 parent 0939eaa commit 37bfbc7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 8 additions & 3 deletions AllowedUploadsPlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,15 @@ function checkUpload($hookName, $params) {
$extension = array_pop(explode('.',$fileName));

$allowedExtensions = $this->getSetting($context->getId(), 'allowedExtensions');
$allowedExtensionsArray = array_filter(array_map('trim', explode(';', $allowedExtensions )), 'strlen');

if (!in_array($extension, $allowedExtensionsArray)){
$form->addError('fileType', __('plugins.generic.allowedUploads.error', array('allowedExtensions' => $allowedExtensions)));
if ($allowedExtensions){

$allowedExtensionsArray = array_filter(array_map('trim', explode(';', $allowedExtensions )), 'strlen');

if (!in_array($extension, $allowedExtensionsArray)){
$form->addError('fileType', __('plugins.generic.allowedUploads.error', array('allowedExtensions' => $allowedExtensions)));
}

}

return false;
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ For OJS 3.1.0.1 or higher
The plugin enables the editor to choose which file extensions are allowed in their journal. NOTE! This is *not* a security plugin. Make sure that your files directory is not a subdirectory of your OJS installation. For more details read the OJS installation instructions.

Copy the plugin folder to plugins/generic/ and enable it. Edit the plugin settings and add a list semicolon separated list of allowed filetypes, for example 'doc; docx; pdf; gif; jpg;'.


TODO
- Add checks and validation when saving the allowed file extensions list

0 comments on commit 37bfbc7

Please sign in to comment.