Socket
Socket
Sign inDemoInstall

jszip

Package Overview
Dependencies
12
Maintainers
3
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.1.4 to 3.1.5

8

CHANGES.md

@@ -7,2 +7,10 @@ ---

### v3.1.5 2017-11-09
- Fix IE11 memory leak (see [#429](https://github.com/Stuk/jszip/pull/429)).
- Handle 2 nodejs deprecations (see [#459](https://github.com/Stuk/jszip/pull/459)).
- Improve the "unsupported format" error message (see [#461](https://github.com/Stuk/jszip/pull/461)).
- Improve webworker compatibility (see [#468](https://github.com/Stuk/jszip/pull/468)).
- Fix nodejs 0.10 compatibility (see [#480](https://github.com/Stuk/jszip/pull/480)).
- Improve the error without type in async() (see [#481](https://github.com/Stuk/jszip/pull/481)).
### v3.1.4 2017-08-24

@@ -9,0 +17,0 @@ - consistently use our own utils object for inheritance (see [#395](https://github.com/Stuk/jszip/pull/395)).

2

lib/index.js

@@ -45,3 +45,3 @@ 'use strict';

// a require('package.json').version doesn't work with webpack, see #327
JSZip.version = "3.1.4";
JSZip.version = "3.1.5";

@@ -48,0 +48,0 @@ JSZip.loadAsync = function (content, options) {

/*!
JSZip v__VERSION__ - A Javascript class for generating and reading zip files
JSZip v__VERSION__ - A JavaScript class for generating and reading zip files
<http://stuartk.com/jszip>

@@ -5,0 +5,0 @@

@@ -11,3 +11,3 @@ 'use strict';

/**
* Create a new nodejs Buffer.
* Create a new nodejs Buffer from an existing content.
* @param {Object} data the data to pass to the constructor.

@@ -17,6 +17,24 @@ * @param {String} encoding the encoding to use.

*/
newBuffer : function(data, encoding){
newBufferFrom: function(data, encoding) {
// XXX We can't use `Buffer.from` which comes from `Uint8Array.from`
// in nodejs v4 (< v.4.5). It's not the expected implementation (and
// has a different signature).
// see https://github.com/nodejs/node/issues/8053
// A condition on nodejs' version won't solve the issue as we don't
// control the Buffer polyfills that may or may not be used.
return new Buffer(data, encoding);
},
/**
* Create a new nodejs Buffer with the specified size.
* @param {Integer} size the size of the buffer.
* @return {Buffer} a new Buffer.
*/
allocBuffer: function (size) {
if (Buffer.alloc) {
return Buffer.alloc(size);
} else {
return new Buffer(size);
}
},
/**
* Find out if an object is a Buffer.

@@ -23,0 +41,0 @@ * @param {Object} b the object to test.

@@ -20,3 +20,3 @@ 'use strict';

/**
* Check that the specifed index will not be too far.
* Check that the specified index will not be too far.
* @param {string} newIndex the index to check.

@@ -23,0 +23,0 @@ * @throws {Error} an Error if the index is out of bounds.

@@ -21,5 +21,3 @@ 'use strict';

* ArrayBuffer/Blob conversion.
* @param {String} resultType the name of the final type
* @param {String} chunkType the type of the data in the given array.
* @param {Array} dataArray the array containing the data chunks to concatenate
* @param {String} type the name of the final type
* @param {String|Uint8Array|Buffer} content the content to transform

@@ -29,13 +27,10 @@ * @param {String} mimeType the mime type of the content, if applicable.

*/
function transformZipOutput(resultType, chunkType, dataArray, mimeType) {
var content = null;
switch(resultType) {
function transformZipOutput(type, content, mimeType) {
switch(type) {
case "blob" :
return utils.newBlob(dataArray, mimeType);
return utils.newBlob(utils.transformTo("arraybuffer", content), mimeType);
case "base64" :
content = concat(chunkType, dataArray);
return base64.encode(content);
default :
content = concat(chunkType, dataArray);
return utils.transformTo(resultType, content);
return utils.transformTo(type, content);
}

@@ -103,3 +98,3 @@ }

try {
var result = transformZipOutput(resultType, chunkType, dataArray, mimeType);
var result = transformZipOutput(resultType, concat(chunkType, dataArray), mimeType);
resolve(result);

@@ -126,4 +121,2 @@ } catch (e) {

case "blob":
internalType = "arraybuffer";
break;
case "arraybuffer":

@@ -130,0 +123,0 @@ internalType = "uint8array";

@@ -23,3 +23,3 @@ 'use strict';

try {
var Builder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder;
var Builder = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder;
var builder = new Builder();

@@ -26,0 +26,0 @@ builder.append(buffer);

@@ -171,3 +171,3 @@ 'use strict';

if (support.nodebuffer) {
return nodejsUtils.newBuffer(str, "utf-8");
return nodejsUtils.newBufferFrom(str, "utf-8");
}

@@ -174,0 +174,0 @@

@@ -29,9 +29,14 @@ 'use strict';

* Create a new blob with the given content and the given type.
* @param {Array[String|ArrayBuffer]} parts the content to put in the blob. DO NOT use
* @param {String|ArrayBuffer} part the content to put in the blob. DO NOT use
* an Uint8Array because the stock browser of android 4 won't accept it (it
* will be silently converted to a string, "[object Uint8Array]").
*
* Use only ONE part to build the blob to avoid a memory leak in IE11 / Edge:
* when a large amount of Array is used to create the Blob, the amount of
* memory consumed is nearly 100 times the original data amount.
*
* @param {String} type the mime type of the blob.
* @return {Blob} the created blob.
*/
exports.newBlob = function(parts, type) {
exports.newBlob = function(part, type) {
exports.checkSupport("blob");

@@ -41,3 +46,3 @@

// Blob constructor
return new Blob(parts, {
return new Blob([part], {
type: type

@@ -50,7 +55,5 @@ });

// deprecated, browser only, old way
var Builder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder;
var Builder = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder;
var builder = new Builder();
for (var i = 0; i < parts.length; i++) {
builder.append(parts[i]);
}
builder.append(part);
return builder.getBlob(type);

@@ -151,3 +154,3 @@ }

try {
return support.nodebuffer && String.fromCharCode.apply(null, nodejsUtils.newBuffer(1)).length === 1;
return support.nodebuffer && String.fromCharCode.apply(null, nodejsUtils.allocBuffer(1)).length === 1;
} catch (e) {

@@ -232,3 +235,3 @@ return false;

"nodebuffer": function(input) {
return stringToArrayLike(input, nodejsUtils.newBuffer(input.length));
return stringToArrayLike(input, nodejsUtils.allocBuffer(input.length));
}

@@ -248,3 +251,3 @@ };

"nodebuffer": function(input) {
return nodejsUtils.newBuffer(input);
return nodejsUtils.newBufferFrom(input);
}

@@ -266,3 +269,3 @@ };

"nodebuffer": function(input) {
return nodejsUtils.newBuffer(new Uint8Array(input));
return nodejsUtils.newBufferFrom(new Uint8Array(input));
}

@@ -278,13 +281,7 @@ };

"arraybuffer": function(input) {
// copy the uint8array: DO NOT propagate the original ArrayBuffer, it
// can be way larger (the whole zip file for example).
var copy = new Uint8Array(input.length);
if (input.length) {
copy.set(input, 0);
}
return copy.buffer;
return input.buffer;
},
"uint8array": identity,
"nodebuffer": function(input) {
return nodejsUtils.newBuffer(input);
return nodejsUtils.newBufferFrom(input);
}

@@ -465,3 +462,4 @@ };

return external.Promise.reject(
new Error("The data of '" + name + "' is in an unsupported format !")
new Error("Can't read the data of '" + name + "'. Is it " +
"in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?")
);

@@ -468,0 +466,0 @@ }

@@ -20,3 +20,3 @@ 'use strict';

/**
* Check that the reader is on the speficied signature.
* Check that the reader is on the specified signature.
* @param {string} expectedSignature the expected signature.

@@ -197,3 +197,3 @@ * @throws {Error} if it is an other signature.

Warning : the zip64 extension is supported, but ONLY if the 64bits integer read from
the zip file can fit into a 32bits integer. This cannot be solved : Javascript represents
the zip file can fit into a 32bits integer. This cannot be solved : JavaScript represents
all numbers as 64-bit double precision IEEE 754 floating point numbers.

@@ -200,0 +200,0 @@ So, we have 53bits for integers and bitwise operations treat everything as 32bits.

@@ -40,17 +40,26 @@ 'use strict';

internalStream: function (type) {
var outputType = type.toLowerCase();
var askUnicodeString = outputType === "string" || outputType === "text";
if (outputType === "binarystring" || outputType === "text") {
outputType = "string";
}
var result = this._decompressWorker();
var result = null, outputType = "string";
try {
if (!type) {
throw new Error("No output type specified.");
}
outputType = type.toLowerCase();
var askUnicodeString = outputType === "string" || outputType === "text";
if (outputType === "binarystring" || outputType === "text") {
outputType = "string";
}
result = this._decompressWorker();
var isUnicodeString = !this._dataBinary;
var isUnicodeString = !this._dataBinary;
if (isUnicodeString && !askUnicodeString) {
result = result.pipe(new utf8.Utf8EncodeWorker());
if (isUnicodeString && !askUnicodeString) {
result = result.pipe(new utf8.Utf8EncodeWorker());
}
if (!isUnicodeString && askUnicodeString) {
result = result.pipe(new utf8.Utf8DecodeWorker());
}
} catch (e) {
result = new GenericWorker("error");
result.error(e);
}
if (!isUnicodeString && askUnicodeString) {
result = result.pipe(new utf8.Utf8DecodeWorker());
}

@@ -57,0 +66,0 @@ return new StreamHelper(result, outputType, "");

{
"name": "jszip",
"version": "3.1.4",
"version": "3.1.5",
"author": "Stuart Knightley <stuart@stuartk.com>",
"description": "Create, read and edit .zip files with Javascript http://stuartk.com/jszip",
"description": "Create, read and edit .zip files with JavaScript http://stuartk.com/jszip",
"scripts": {

@@ -42,3 +42,3 @@ "test": "npm run test-node && npm run test-browser",

"grunt-cli": "~1.1.0",
"grunt-saucelabs": "~8.6.2",
"grunt-saucelabs": "8.6.2",
"grunt-contrib-connect": "1.0.0",

@@ -51,4 +51,5 @@ "jshint": "~2.9.1",

"grunt-contrib-uglify": "~1.0.0",
"phantomjs-prebuilt": "2.1.15",
"jszip-utils": "~0.0.2",
"package-json-versionify": "~1.0.2",
"package-json-versionify": "1.0.2",
"qunit-cli": "~0.2.0",

@@ -55,0 +56,0 @@ "qunitjs": "~1.23.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc