Skip to content

Commit

Permalink
Updates to release v5.5.2 fixes #1817 fixes #1822
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-v committed Oct 13, 2022
1 parent bbc9ca6 commit 35c29cd
Show file tree
Hide file tree
Showing 22 changed files with 80 additions and 59 deletions.
9 changes: 9 additions & 0 deletions CHANGE.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/bootstrap-fileinput@5.5.1/css/fileinput.min.css" media="all" rel="stylesheet" type="text/css" />
<link href="https://cdn.jsdelivr.net/gh/kartik-v/bootstrap-fileinput@5.5.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/bootstrap-fileinput@5.5.1/css/fileinput-rtl.min.css" media="all" rel="stylesheet" type="text/css" /-->
<!-- link href="https://cdn.jsdelivr.net/gh/kartik-v/bootstrap-fileinput@5.5.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>
Expand All @@ -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/bootstrap-fileinput@5.5.1/js/plugins/buffer.min.js" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/gh/kartik-v/bootstrap-fileinput@5.5.1/js/plugins/filetype.min.js" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/gh/kartik-v/bootstrap-fileinput@5.5.2/js/plugins/buffer.min.js" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/gh/kartik-v/bootstrap-fileinput@5.5.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/bootstrap-fileinput@5.5.1/js/plugins/piexif.min.js" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/gh/kartik-v/bootstrap-fileinput@5.5.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/bootstrap-fileinput@5.5.1/js/plugins/sortable.min.js" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/gh/kartik-v/bootstrap-fileinput@5.5.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/bootstrap@5.2.0/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/bootstrap-fileinput@5.5.1/js/fileinput.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/kartik-v/bootstrap-fileinput@5.5.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/bootstrap-fileinput@5.5.1/themes/fas/theme.min.js"></script -->
<!-- script src="https://cdn.jsdelivr.net/gh/kartik-v/bootstrap-fileinput@5.5.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/bootstrap-fileinput@5.5.1/js/locales/LANG.js"></script>
<script src="https://cdn.jsdelivr.net/gh/kartik-v/bootstrap-fileinput@5.5.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.

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -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 <kartikv2@gmail.com>"
Expand Down
2 changes: 1 addition & 1 deletion css/fileinput-rtl.css
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion css/fileinput-rtl.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion css/fileinput.css
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion css/fileinput.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/index-bs3.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
* bootstrap-fileinput v5.5.1
* bootstrap-fileinput v5.5.2
* http://plugins.krajee.com/file-input
*
* Author: Kartik Visweswaran
Expand Down
2 changes: 1 addition & 1 deletion examples/index-bs4.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
* bootstrap-fileinput v5.5.1
* bootstrap-fileinput v5.5.2
* http://plugins.krajee.com/file-input
*
* Author: Kartik Visweswaran
Expand Down
2 changes: 1 addition & 1 deletion examples/index-bs5.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
* bootstrap-fileinput v5.5.1
* bootstrap-fileinput v5.5.2
* http://plugins.krajee.com/file-input
*
* Author: Kartik Visweswaran
Expand Down
5 changes: 3 additions & 2 deletions js/fileinput.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* bootstrap-fileinput v5.5.1
* bootstrap-fileinput v5.5.2
* http://plugins.krajee.com/file-input
*
* Author: Kartik Visweswaran
Expand Down Expand Up @@ -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':
Expand Down
4 changes: 2 additions & 2 deletions js/fileinput.min.js

Large diffs are not rendered by default.

68 changes: 40 additions & 28 deletions js/plugins/filetype.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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: {
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -483,6 +494,7 @@ class FileTypeParser {
}

await tokenizer.ignore(id3HeaderLength);
console.log("KV SAYS", typeof tokenizer, tokenizer);
return fileTypeFromTokenizer(tokenizer); // Skip ID3 header, recursion
}

Expand Down Expand Up @@ -1551,7 +1563,7 @@ class FileTypeParser {
mime: 'application/x-asar',
};
}
} catch(err) {
} catch (err) {
console.log(err);
}
}
Expand Down
3 changes: 1 addition & 2 deletions js/plugins/filetype.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion nuget/Package.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <kartikv2@gmail.com>"
Expand Down
2 changes: 1 addition & 1 deletion scss/fileinput-rtl.scss
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion scss/fileinput.scss
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion scss/themes/explorer-fa4/theme.scss
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion scss/themes/explorer-fa5/theme.scss
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion scss/themes/explorer-fa6/theme.scss
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion scss/themes/explorer/theme.scss
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down

0 comments on commit 35c29cd

Please sign in to comment.