Do not attempt to resize non-images in attachment upload
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 16 Jun 2020 10:52:54 +0000 (12:52 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 16 Jun 2020 10:57:22 +0000 (12:57 +0200)
Fixes #3059

wcfsetup/install/files/js/WCF.Attachment.js

index d170624e2171c61fb039f547063ba8c4cfd168ef..b31e5ff72e8a68d1e47787ae80d4e3d5993a3adb 100644 (file)
@@ -333,6 +333,12 @@ WCF.Attachment.Upload = WCF.Upload.extend({
                                // As our resizer is based on Pica it will use multiple workers per image if possible.
                                promise = Array.prototype.reduce.call(files, (function (acc, file) {
                                        return acc.then((function (arr) {
+                                               // Ignore anything that is not one of the 3 basic image types.
+                                               if (['image/png', 'image/gif', 'image/jpeg'].indexOf(file.type) === -1) {
+                                                       arr.push(file);
+                                                       return arr;
+                                               }
+                                               
                                                var timeout = new Promise(function (resolve, reject) {
                                                        // We issue one timeout per image, thus multiple timeout
                                                        // handlers will run in parallel