From 66f2b155cecbd6b066fbc6c1efa7317e24f79915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Thu, 30 Aug 2018 14:02:50 +0200 Subject: [PATCH] Fix empty mime type filter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the mime type is an empty array no filter should be applied. However, the filter was loosely compared to an empty array, but as arrays are objects then it became an implicit strict equality comparison which always failed due to being different objects. Now the length of the array is compared instead, and also moved outside the loop as it is not needed to check it for each file. Signed-off-by: Daniel Calviño Sánchez --- core/js/oc-dialogs.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js index d346b5231d1..a9f9426c488 100644 --- a/core/js/oc-dialogs.js +++ b/core/js/oc-dialogs.js @@ -841,9 +841,9 @@ var OCdialogs = { filter = [filter]; } self.filepicker.filesClient.getFolderContents(dir).then(function(status, files) { - if (filter) { + if (filter && filter.length > 0) { files = files.filter(function (file) { - return filter == [] || file.type === 'dir' || filter.indexOf(file.mimetype) !== -1; + return file.type === 'dir' || filter.indexOf(file.mimetype) !== -1; }); } files = files.sort(function(a, b) {