Skip to content

Commit acb4c26

Browse files
committed
Reporting correct compressed/uncompressed file sizes for zip64 file entries
1 parent 3109282 commit acb4c26

File tree

4 files changed

+46
-14
lines changed

4 files changed

+46
-14
lines changed

dist/jszip.js

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
3-
JSZip v3.2.1 - A JavaScript class for generating and reading zip files
3+
JSZip v3.2.2 - A JavaScript class for generating and reading zip files
44
<http://stuartk.com/jszip>
55
66
(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
@@ -1859,6 +1859,22 @@ DataReader.prototype = {
18591859
this.index += size;
18601860
return result;
18611861
},
1862+
/**
1863+
* Get the next number with a given byte size.
1864+
* Same as readInt but using * 256 so there is no conversion to int32.
1865+
* @param {number} size the number of bytes to read.
1866+
* @return {number} the corresponding number.
1867+
*/
1868+
readLong: function(size) {
1869+
var result = 0,
1870+
i;
1871+
this.checkOffset(size);
1872+
for (i = this.index + size - 1; i >= this.index; i--) {
1873+
result = (result * 256) + this.byteAt(i);
1874+
}
1875+
this.index += size;
1876+
return result;
1877+
},
18621878
/**
18631879
* Get the next string with a given byte size.
18641880
* @param {number} size the number of bytes to read.
@@ -3950,13 +3966,13 @@ ZipEntry.prototype = {
39503966
// I really hope that these 64bits integer can fit in 32 bits integer, because js
39513967
// won't let us have more.
39523968
if (this.uncompressedSize === utils.MAX_VALUE_32BITS) {
3953-
this.uncompressedSize = extraReader.readInt(8);
3969+
this.uncompressedSize = extraReader.readLong(8);
39543970
}
39553971
if (this.compressedSize === utils.MAX_VALUE_32BITS) {
3956-
this.compressedSize = extraReader.readInt(8);
3972+
this.compressedSize = extraReader.readLong(8);
39573973
}
39583974
if (this.localHeaderOffset === utils.MAX_VALUE_32BITS) {
3959-
this.localHeaderOffset = extraReader.readInt(8);
3975+
this.localHeaderOffset = extraReader.readLong(8);
39603976
}
39613977
if (this.diskNumberStart === utils.MAX_VALUE_32BITS) {
39623978
this.diskNumberStart = extraReader.readInt(4);
@@ -4608,7 +4624,7 @@ var Z_DEFLATED = 8;
46084624
/* internal
46094625
* Deflate.chunks -> Array
46104626
*
4611-
* Chunks of output data, if [[Deflate#onData]] not overridden.
4627+
* Chunks of output data, if [[Deflate#onData]] not overriden.
46124628
**/
46134629

46144630
/**
@@ -4850,7 +4866,7 @@ Deflate.prototype.push = function (data, mode) {
48504866

48514867
/**
48524868
* Deflate#onData(chunk) -> Void
4853-
* - chunk (Uint8Array|Array|String): output data. Type of array depends
4869+
* - chunk (Uint8Array|Array|String): ouput data. Type of array depends
48544870
* on js engine support. When string output requested, each chunk
48554871
* will be string.
48564872
*
@@ -4993,7 +5009,7 @@ var toString = Object.prototype.toString;
49935009
/* internal
49945010
* inflate.chunks -> Array
49955011
*
4996-
* Chunks of output data, if [[Inflate#onData]] not overridden.
5012+
* Chunks of output data, if [[Inflate#onData]] not overriden.
49975013
**/
49985014

49995015
/**
@@ -5268,7 +5284,7 @@ Inflate.prototype.push = function (data, mode) {
52685284

52695285
/**
52705286
* Inflate#onData(chunk) -> Void
5271-
* - chunk (Uint8Array|Array|String): output data. Type of array depends
5287+
* - chunk (Uint8Array|Array|String): ouput data. Type of array depends
52725288
* on js engine support. When string output requested, each chunk
52735289
* will be string.
52745290
*
@@ -5295,7 +5311,7 @@ Inflate.prototype.onEnd = function (status) {
52955311
if (status === c.Z_OK) {
52965312
if (this.options.to === 'string') {
52975313
// Glue & convert here, until we teach pako to send
5298-
// utf8 aligned strings to onData
5314+
// utf8 alligned strings to onData
52995315
this.result = this.chunks.join('');
53005316
} else {
53015317
this.result = utils.flattenChunks(this.chunks);

dist/jszip.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/reader/DataReader.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,22 @@ DataReader.prototype = {
6666
this.index += size;
6767
return result;
6868
},
69+
/**
70+
* Get the next number with a given byte size.
71+
* Same as readInt but using * 256 so there is no conversion to int32.
72+
* @param {number} size the number of bytes to read.
73+
* @return {number} the corresponding number.
74+
*/
75+
readLong: function(size) {
76+
var result = 0,
77+
i;
78+
this.checkOffset(size);
79+
for (i = this.index + size - 1; i >= this.index; i--) {
80+
result = (result * 256) + this.byteAt(i);
81+
}
82+
this.index += size;
83+
return result;
84+
},
6985
/**
7086
* Get the next string with a given byte size.
7187
* @param {number} size the number of bytes to read.

lib/zipEntry.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,13 @@ ZipEntry.prototype = {
174174
// I really hope that these 64bits integer can fit in 32 bits integer, because js
175175
// won't let us have more.
176176
if (this.uncompressedSize === utils.MAX_VALUE_32BITS) {
177-
this.uncompressedSize = extraReader.readInt(8);
177+
this.uncompressedSize = extraReader.readLong(8);
178178
}
179179
if (this.compressedSize === utils.MAX_VALUE_32BITS) {
180-
this.compressedSize = extraReader.readInt(8);
180+
this.compressedSize = extraReader.readLong(8);
181181
}
182182
if (this.localHeaderOffset === utils.MAX_VALUE_32BITS) {
183-
this.localHeaderOffset = extraReader.readInt(8);
183+
this.localHeaderOffset = extraReader.readLong(8);
184184
}
185185
if (this.diskNumberStart === utils.MAX_VALUE_32BITS) {
186186
this.diskNumberStart = extraReader.readInt(4);

0 commit comments

Comments
 (0)