Sfoglia il codice sorgente

Fix #1030: Correct image dimension validation to consider non JPEG images

Kartik Visweswaran 7 anni fa
parent
commit
f6a7b20132
3 ha cambiato i file con 17 aggiunte e 11 eliminazioni
  1. 2 1
      CHANGE.md
  2. 15 10
      js/fileinput.js
  3. 0 0
      js/fileinput.min.js

+ 2 - 1
CHANGE.md

@@ -3,10 +3,11 @@ Change Log: `bootstrap-fileinput`
 
 
 ## version 4.4.3 (_under development_)
 ## version 4.4.3 (_under development_)
 
 
-**Date:** 17-Jul-2017
+**Date:** 29-Jul-2017
 
 
 - (enh #1015): Enhancement to RTL styling.
 - (enh #1015): Enhancement to RTL styling.
 - (enh #1006): Update Farsi Translations.
 - (enh #1006): Update Farsi Translations.
+- (bug #1030): Correct image dimension validation to consider non JPEG images.
 
 
 ## version 4.4.2
 ## version 4.4.2
 
 

+ 15 - 10
js/fileinput.js

@@ -279,8 +279,11 @@
         setOrientation: function (buffer, callback) {
         setOrientation: function (buffer, callback) {
             var scanner = new DataView(buffer), idx = 0, value = 1, // Non-rotated is the default
             var scanner = new DataView(buffer), idx = 0, value = 1, // Non-rotated is the default
                 maxBytes, uInt16, exifLength;
                 maxBytes, uInt16, exifLength;
-            if (scanner.getUint16(idx) !== 0xFFD8 || buffer.length < 2) {
-                return; // not a proper JPEG
+            if (scanner.getUint16(idx) !== 0xFFD8 || buffer.length < 2) { // not a proper JPEG                
+                if (callback) {
+                    callback();
+                }
+                return;
             }
             }
             idx += 2;
             idx += 2;
             maxBytes = scanner.byteLength;
             maxBytes = scanner.byteLength;
@@ -2511,15 +2514,17 @@
                 var $img = $preview.find('#' + previewId + ' img');
                 var $img = $preview.find('#' + previewId + ' img');
                 if ($img.length && self.autoOrientImage) {
                 if ($img.length && self.autoOrientImage) {
                     $h.validateOrientation(file, function (value) {
                     $h.validateOrientation(file, function (value) {
-                        if (value) {
-                            var $zoomImg = $preview.find('#zoom-' + previewId + ' img'), css = 'rotate-' + value;
-                            if (value > 4) {
-                                css += ($img.width() > $img.height() ? ' is-portrait-gt4' : ' is-landscape-gt4');
-                            }
-                            $h.addCss($img, css);
-                            $h.addCss($zoomImg, css);
-                            self._raise('fileimageoriented', {'$img': $img, 'file': file});
+                        if (!value) {
+                            self._validateImage(previewId, caption, ftype, fsize, iData);
+                            return;
+                        }
+                        var $zoomImg = $preview.find('#zoom-' + previewId + ' img'), css = 'rotate-' + value;
+                        if (value > 4) {
+                            css += ($img.width() > $img.height() ? ' is-portrait-gt4' : ' is-landscape-gt4');
                         }
                         }
+                        $h.addCss($img, css);
+                        $h.addCss($zoomImg, css);
+                        self._raise('fileimageoriented', {'$img': $img, 'file': file});
                         self._validateImage(previewId, caption, ftype, fsize, iData);
                         self._validateImage(previewId, caption, ftype, fsize, iData);
                         $h.adjustOrientedImage($img);
                         $h.adjustOrientedImage($img);
                     });
                     });

File diff suppressed because it is too large
+ 0 - 0
js/fileinput.min.js


Some files were not shown because too many files changed in this diff