Browse Source

Updates to release v5.5.2 fixes #1817 fixes #1822

Kartik Visweswaran 2 years ago
parent
commit
35c29cd9fd

+ 9 - 0
CHANGE.md

@@ -1,6 +1,15 @@
 Change Log: `bootstrap-fileinput`
 =================================
 
+## version 5.5.2
+
+**Date**: 13-Oct-2022
+
+- (bug #1822): Correct file type tokenizer parsing.
+- (enh #1821): Update Indonesian Translations.
+- (enh #1819): Update Chinese Translations.
+- (enh #1817): Fix invalid signature detection.
+- 
 ## version 5.5.1
 
 **Date**: 17-Aug-2022

+ 9 - 9
README.md

@@ -92,10 +92,10 @@ Step 1: Load the following assets on your page in the order mentioned.
 <!-- link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css" crossorigin="anonymous" -->
 
 <!-- the fileinput plugin styling CSS file -->
-<link href="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].1/css/fileinput.min.css" media="all" rel="stylesheet" type="text/css" />
+<link href="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].2/css/fileinput.min.css" media="all" rel="stylesheet" type="text/css" />
 
 <!-- if using RTL (Right-To-Left) orientation, load the RTL CSS file after fileinput.css by uncommenting below -->
-<!-- link href="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].1/css/fileinput-rtl.min.css" media="all" rel="stylesheet" type="text/css" /-->
+<!-- link href="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].2/css/fileinput-rtl.min.css" media="all" rel="stylesheet" type="text/css" /-->
 
 <!-- the jQuery Library -->
 <script src="https://code.jquery.com/jquery-3.6.0.min.js" crossorigin="anonymous"></script>
@@ -106,29 +106,29 @@ Step 1: Load the following assets on your page in the order mentioned.
      selected file (note: this will involve a small processing overhead in scanning of file contents locally). If you 
      do not load these scripts then the mime type parsing will largely be derived using the extension in the filename
      and some basic file content parsing signatures. -->
-<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].1/js/plugins/buffer.min.js" type="text/javascript"></script>
-<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].1/js/plugins/filetype.min.js" type="text/javascript"></script>
+<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].2/js/plugins/buffer.min.js" type="text/javascript"></script>
+<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].2/js/plugins/filetype.min.js" type="text/javascript"></script>
 
 <!-- piexif.min.js is needed for auto orienting image files OR when restoring exif data in resized images and when you
     wish to resize images before upload. This must be loaded before fileinput.min.js -->
-<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].1/js/plugins/piexif.min.js" type="text/javascript"></script>
+<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].2/js/plugins/piexif.min.js" type="text/javascript"></script>
 
 <!-- sortable.min.js is only needed if you wish to sort / rearrange files in initial preview. 
     This must be loaded before fileinput.min.js -->
-<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].1/js/plugins/sortable.min.js" type="text/javascript"></script>
+<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].2/js/plugins/sortable.min.js" type="text/javascript"></script>
 
 <!-- bootstrap.bundle.min.js below is needed if you wish to zoom and preview file content in a detail modal
     dialog. bootstrap 5.x or 4.x is supported. You can also use the bootstrap js 3.3.x versions. -->
 <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
 
 <!-- the main fileinput plugin script JS file -->
-<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].1/js/fileinput.min.js"></script>
+<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].2/js/fileinput.min.js"></script>
 
 <!-- following theme script is needed to use the Font Awesome 5.x theme (`fas`). Uncomment if needed. -->
-<!-- script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].1/themes/fas/theme.min.js"></script -->
+<!-- script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].2/themes/fas/theme.min.js"></script -->
 
 <!-- optionally if you need translation for your language then include the locale file as mentioned below (replace LANG.js with your language locale) -->
-<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].1/js/locales/LANG.js"></script>
+<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].2/js/locales/LANG.js"></script>
 ```
 With v5.2.1, the plugin is able to automatically detect the bootstrap library version and deliver the relevant bootstrap specific functionality (if you have loaded the bootstrap.min.js before fileinput.min.js). In case of any issues - you can explicitly set the bootstrap version by setting the following variable before the plugin initialization script.
 

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "bootstrap-fileinput",
-  "version": "5.5.1",
+  "version": "5.5.2",
   "homepage": "https://github.com/kartik-v/bootstrap-fileinput",
   "authors": [
     "Kartik Visweswaran <[email protected]>"

+ 1 - 1
css/fileinput-rtl.css

@@ -1,5 +1,5 @@
 /*!
- * bootstrap-fileinput v5.5.1
+ * bootstrap-fileinput v5.5.2
  * http://plugins.krajee.com/file-input
  *
  * Krajee RTL (Right To Left) default styling for bootstrap-fileinput.

+ 1 - 1
css/fileinput-rtl.min.css

@@ -1,5 +1,5 @@
 /*!
- * bootstrap-fileinput v5.5.1
+ * bootstrap-fileinput v5.5.2
  * http://plugins.krajee.com/file-input
  *
  * Krajee RTL (Right To Left) default styling for bootstrap-fileinput.

+ 1 - 1
css/fileinput.css

@@ -1,5 +1,5 @@
 /*!
- * bootstrap-fileinput v5.5.1
+ * bootstrap-fileinput v5.5.2
  * http://plugins.krajee.com/file-input
  *
  * Krajee default styling for bootstrap-fileinput.

+ 1 - 1
css/fileinput.min.css

@@ -1,5 +1,5 @@
 /*!
- * bootstrap-fileinput v5.5.1
+ * bootstrap-fileinput v5.5.2
  * http://plugins.krajee.com/file-input
  *
  * Krajee default styling for bootstrap-fileinput.

+ 1 - 1
examples/index-bs3.html

@@ -1,5 +1,5 @@
 <!--
-* bootstrap-fileinput v5.5.1
+* bootstrap-fileinput v5.5.2
 * http://plugins.krajee.com/file-input
 *
 * Author: Kartik Visweswaran

+ 1 - 1
examples/index-bs4.html

@@ -1,5 +1,5 @@
 <!--
-* bootstrap-fileinput v5.5.1
+* bootstrap-fileinput v5.5.2
 * http://plugins.krajee.com/file-input
 *
 * Author: Kartik Visweswaran

+ 1 - 1
examples/index-bs5.html

@@ -1,5 +1,5 @@
 <!--
-* bootstrap-fileinput v5.5.1
+* bootstrap-fileinput v5.5.2
 * http://plugins.krajee.com/file-input
 *
 * Author: Kartik Visweswaran

+ 3 - 2
js/fileinput.js

@@ -1,5 +1,5 @@
 /*!
- * bootstrap-fileinput v5.5.1
+ * bootstrap-fileinput v5.5.2
  * http://plugins.krajee.com/file-input
  *
  * Author: Kartik Visweswaran
@@ -445,7 +445,8 @@
             }
             return str.match(/^\s*<\?xml/i) && (str.match(/<!DOCTYPE svg/i) || str.match(/<svg/i));
         },
-        getMimeType: function (signature, contents, type) {
+        getMimeType: function (sign, contents, type) {
+            var signature = sign || "";
             switch (signature) {
                 case 'ffd8ffe0':
                 case 'ffd8ffe1':

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


+ 40 - 28
js/plugins/filetype.js

@@ -11,7 +11,7 @@
 var KrajeeFileTypeConfig = {
     minimumBytes: 4100, // A fair amount of file-types are detectable within this range,
     defaultMessages: 'End-Of-Stream',
-    tarHeaderChecksumMatches: function(buffer, offset = 0) {
+    tarHeaderChecksumMatches: function (buffer, offset = 0) {
         var readSum = Number.parseInt(buffer.toString('utf8', 148, 154).replace(/\0.*$/, '').trim(), 8); // Read sum in header
         if (Number.isNaN(readSum)) {
             return false;
@@ -30,12 +30,12 @@ var KrajeeFileTypeConfig = {
         return readSum === sum;
     },
     uint32SyncSafeToken: {
-        get: function(buffer, offset) {
+        get: function (buffer, offset) {
             return (buffer[offset + 3] & 0x7F) | ((buffer[offset + 2]) << 7) | ((buffer[offset + 1]) << 14) | ((buffer[offset]) << 21);
         },
         len: 4,
     },
-    dv: function(array) {
+    dv: function (array) {
         return new DataView(array.buffer, array.byteOffset);
     },
     Token: {
@@ -44,10 +44,10 @@ var KrajeeFileTypeConfig = {
          */
         UINT8: {
             len: 1,
-            get: function(array, offset) {
+            get: function (array, offset) {
                 return KrajeeFileTypeConfig.dv(array).getUint8(offset);
             },
-            put: function(array, offset, value) {
+            put: function (array, offset, value) {
                 KrajeeFileTypeConfig.dv(array).setUint8(offset, value);
                 return offset + 1;
             }
@@ -57,10 +57,10 @@ var KrajeeFileTypeConfig = {
          */
         UINT16_LE: {
             len: 2,
-            get: function(array, offset) {
+            get: function (array, offset) {
                 return KrajeeFileTypeConfig.dv(array).getUint16(offset, true);
             },
-            put: function(array, offset, value) {
+            put: function (array, offset, value) {
                 KrajeeFileTypeConfig.dv(array).setUint16(offset, value, true);
                 return offset + 2;
             }
@@ -70,10 +70,10 @@ var KrajeeFileTypeConfig = {
          */
         UINT16_BE: {
             len: 2,
-            get: function(array, offset) {
+            get: function (array, offset) {
                 return KrajeeFileTypeConfig.dv(array).getUint16(offset);
             },
-            put: function(array, offset, value) {
+            put: function (array, offset, value) {
                 KrajeeFileTypeConfig.dv(array).setUint16(offset, value);
                 return offset + 2;
             }
@@ -83,10 +83,10 @@ var KrajeeFileTypeConfig = {
          */
         INT32_BE: {
             len: 4,
-            get: function(array, offset) {
+            get: function (array, offset) {
                 return KrajeeFileTypeConfig.dv(array).getInt32(offset);
             },
-            put: function(array, offset, value) {
+            put: function (array, offset, value) {
                 KrajeeFileTypeConfig.dv(array).setInt32(offset, value);
                 return offset + 4;
             }
@@ -96,10 +96,10 @@ var KrajeeFileTypeConfig = {
          */
         UINT32_LE: {
             len: 4,
-            get: function(array, offset) {
+            get: function (array, offset) {
                 return KrajeeFileTypeConfig.dv(array).getUint32(offset, true);
             },
-            put: function(array, offset, value) {
+            put: function (array, offset, value) {
                 KrajeeFileTypeConfig.dv(array).setUint32(offset, value, true);
                 return offset + 4;
             }
@@ -109,10 +109,10 @@ var KrajeeFileTypeConfig = {
          */
         UINT32_BE: {
             len: 4,
-            get: function(array, offset) {
+            get: function (array, offset) {
                 return KrajeeFileTypeConfig.dv(array).getUint32(offset);
             },
-            put: function(array, offset, value) {
+            put: function (array, offset, value) {
                 KrajeeFileTypeConfig.dv(array).setUint32(offset, value);
                 return offset + 4;
             }
@@ -123,10 +123,10 @@ var KrajeeFileTypeConfig = {
          */
         UINT64_LE: {
             len: 8,
-            get: function(array, offset) {
+            get: function (array, offset) {
                 return KrajeeFileTypeConfig.dv(array).getBigUint64(offset, true);
             },
-            put: function(array, offset, value) {
+            put: function (array, offset, value) {
                 KrajeeFileTypeConfig.dv(array).setBigUint64(offset, value, true);
                 return offset + 8;
             }
@@ -136,10 +136,10 @@ var KrajeeFileTypeConfig = {
          */
         UINT64_BE: {
             len: 8,
-            get: function(array, offset) {
+            get: function (array, offset) {
                 return KrajeeFileTypeConfig.dv(array).getBigUint64(offset);
             },
-            put: function(array, offset, value) {
+            put: function (array, offset, value) {
                 KrajeeFileTypeConfig.dv(array).setBigUint64(offset, value);
                 return offset + 8;
             }
@@ -164,6 +164,17 @@ class StringType {
     }
 }
 
+
+async function fileTypeFromTokenizer(tokenizer) {
+    try {
+        return new FileTypeParser().parse(tokenizer);
+    } catch (error) {
+        if (!(error instanceof EndOfStreamError)) {
+            throw error;
+        }
+    }
+}
+
 class BufferTokenizer {
     /**
      * Construct BufferTokenizer
@@ -345,18 +356,18 @@ class FileTypeParser {
     }
 
     async parse(input) {
-        if (!(input instanceof Uint8Array || input instanceof ArrayBuffer)) {
+        if (!(input instanceof Uint8Array || input instanceof ArrayBuffer || input instanceof BufferTokenizer)) {
             throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`Buffer\` or \`ArrayBuffer\`, got \`${typeof input}\``);
         }
-
-        const buffer = input instanceof Uint8Array ? input : new Uint8Array(input);
-
-        if (!(buffer && buffer.length > 1)) {
-            return;
+        let tokenizer = input;
+        if (!(tokenizer instanceof BufferTokenizer)) {
+            const buffer = input instanceof Uint8Array ? input : new Uint8Array(input);
+            if (!(buffer && buffer.length > 1)) {
+                return;
+            }
+            tokenizer = new BufferTokenizer(buffer);
         }
 
-        const tokenizer = new BufferTokenizer(buffer);
-
         try {
             return this.parseTokenizer(tokenizer);
         } catch (error) {
@@ -483,6 +494,7 @@ class FileTypeParser {
             }
 
             await tokenizer.ignore(id3HeaderLength);
+            console.log("KV SAYS", typeof tokenizer, tokenizer);
             return fileTypeFromTokenizer(tokenizer); // Skip ID3 header, recursion
         }
 
@@ -1551,7 +1563,7 @@ class FileTypeParser {
                             mime: 'application/x-asar',
                         };
                     }
-                } catch(err) {
+                } catch (err) {
                     console.log(err);
                 }
             }

File diff suppressed because it is too large
+ 0 - 1
js/plugins/filetype.min.js


+ 1 - 1
nuget/Package.nuspec

@@ -3,7 +3,7 @@
   <metadata>
     <id>bootstrap-fileinput</id>
 	<title>bootstrap-fileinput</title>
-    <version>5.5.0</version>
+    <version>5.5.2</version>
     <authors>Kartik Visweswaran</authors>
     <owners>Kartik Visweswaran</owners>
     <licenseUrl>https://github.com/kartik-v/bootstrap-fileinput/blob/master/LICENSE.md</licenseUrl>

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "bootstrap-fileinput",
-  "version": "5.5.1",
+  "version": "5.5.2",
   "homepage": "https://github.com/kartik-v/bootstrap-fileinput",
   "authors": [
     "Kartik Visweswaran <[email protected]>"

+ 1 - 1
scss/fileinput-rtl.scss

@@ -1,5 +1,5 @@
 /*!
- * bootstrap-fileinput v5.5.1
+ * bootstrap-fileinput v5.5.2
  * http://plugins.krajee.com/file-input
  *
  * Krajee RTL (Right To Left) default styling for bootstrap-fileinput.

+ 1 - 1
scss/fileinput.scss

@@ -1,5 +1,5 @@
 /*!
- * bootstrap-fileinput v5.5.1
+ * bootstrap-fileinput v5.5.2
  * http://plugins.krajee.com/file-input
  *
  * Krajee default styling for bootstrap-fileinput.

+ 1 - 1
scss/themes/explorer-fa4/theme.scss

@@ -1,5 +1,5 @@
 /*!
- * bootstrap-fileinput v5.5.1
+ * bootstrap-fileinput v5.5.2
  * http://plugins.krajee.com/file-input
  *
  * Krajee Explorer Font Awesome 4.x theme style for bootstrap-fileinput. Load this theme file after loading

+ 1 - 1
scss/themes/explorer-fa5/theme.scss

@@ -1,5 +1,5 @@
 /*!
- * bootstrap-fileinput v5.5.1
+ * bootstrap-fileinput v5.5.2
  * http://plugins.krajee.com/file-input
  *
  * Krajee Explorer Font Awesome 5.x theme style for bootstrap-fileinput. Load this theme file after loading

+ 1 - 1
scss/themes/explorer-fa6/theme.scss

@@ -1,5 +1,5 @@
 /*!
- * bootstrap-fileinput v5.5.1
+ * bootstrap-fileinput v5.5.2
  * http://plugins.krajee.com/file-input
  *
  * Krajee Explorer Font Awesome 6.x theme style for bootstrap-fileinput. Load this theme file after loading

+ 1 - 1
scss/themes/explorer/theme.scss

@@ -1,5 +1,5 @@
 /*!
- * bootstrap-fileinput v5.5.1
+ * bootstrap-fileinput v5.5.2
  * http://plugins.krajee.com/file-input
  *
  * Krajee Explorer theme style for bootstrap-fileinput. Load this theme file after loading `fileinput.css`.

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