Skip to content

Commit

Permalink
Merge pull request #8172 from TriPhoenix/file-upload-allow-whitelist
Browse files Browse the repository at this point in the history
[FIX] Allow unknown file types if no allowed whitelist has been set (#7074)
  • Loading branch information
rodrigok committed Sep 18, 2017
1 parent adc895a commit b3cadfb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion packages/rocketchat-lib/lib/fileUploadRestrictions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ RocketChat.fileUploadMediaWhiteList = function() {

RocketChat.fileUploadIsValidContentType = function(type) {
const list = RocketChat.fileUploadMediaWhiteList();
if (!list || _.contains(list, type)) {
if (!list) {
return true;
}

if (!type) {
return false;
}

if (_.contains(list, type)) {
return true;
} else {
const wildCardGlob = '/*';
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-ui/client/lib/fileUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fileUpload = function(filesToUpload) {
return;
}

if (!file.file.type || !RocketChat.fileUploadIsValidContentType(file.file.type)) {
if (!RocketChat.fileUploadIsValidContentType(file.file.type)) {
swal({
title: t('FileUpload_MediaType_NotAccepted'),
text: file.file.type || `*.${ s.strRightBack(file.file.name, '.') }`,
Expand Down

0 comments on commit b3cadfb

Please sign in to comment.