Skip to content

Reporting correct compressed/uncompressed file sizes for zip64 #654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions dist/jszip.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!

JSZip v3.3.0 - A JavaScript class for generating and reading zip files
JSZip v3.4.0 - A JavaScript class for generating and reading zip files
<http://stuartk.com/jszip>

(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
Expand Down Expand Up @@ -1859,6 +1859,22 @@ DataReader.prototype = {
this.index += size;
return result;
},
/**
* Get the next number with a given byte size.
* Same as readInt but using * 256 so there is no conversion to int32.
* @param {number} size the number of bytes to read.
* @return {number} the corresponding number.
*/
readLong: function(size) {
var result = 0,
i;
this.checkOffset(size);
for (i = this.index + size - 1; i >= this.index; i--) {
result = (result * 256) + this.byteAt(i);
}
this.index += size;
return result;
},
/**
* Get the next string with a given byte size.
* @param {number} size the number of bytes to read.
Expand Down Expand Up @@ -3950,13 +3966,13 @@ ZipEntry.prototype = {
// I really hope that these 64bits integer can fit in 32 bits integer, because js
// won't let us have more.
if (this.uncompressedSize === utils.MAX_VALUE_32BITS) {
this.uncompressedSize = extraReader.readInt(8);
this.uncompressedSize = extraReader.readLong(8);
}
if (this.compressedSize === utils.MAX_VALUE_32BITS) {
this.compressedSize = extraReader.readInt(8);
this.compressedSize = extraReader.readLong(8);
}
if (this.localHeaderOffset === utils.MAX_VALUE_32BITS) {
this.localHeaderOffset = extraReader.readInt(8);
this.localHeaderOffset = extraReader.readLong(8);
}
if (this.diskNumberStart === utils.MAX_VALUE_32BITS) {
this.diskNumberStart = extraReader.readInt(4);
Expand Down
4 changes: 2 additions & 2 deletions dist/jszip.min.js

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions lib/reader/DataReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,22 @@ DataReader.prototype = {
this.index += size;
return result;
},
/**
* Get the next number with a given byte size.
* Same as readInt but using * 256 so there is no conversion to int32.
* @param {number} size the number of bytes to read.
* @return {number} the corresponding number.
*/
readLong: function(size) {
var result = 0,
i;
this.checkOffset(size);
for (i = this.index + size - 1; i >= this.index; i--) {
result = (result * 256) + this.byteAt(i);
}
this.index += size;
return result;
},
/**
* Get the next string with a given byte size.
* @param {number} size the number of bytes to read.
Expand Down
6 changes: 3 additions & 3 deletions lib/zipEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@ ZipEntry.prototype = {
// I really hope that these 64bits integer can fit in 32 bits integer, because js
// won't let us have more.
if (this.uncompressedSize === utils.MAX_VALUE_32BITS) {
this.uncompressedSize = extraReader.readInt(8);
this.uncompressedSize = extraReader.readLong(8);
}
if (this.compressedSize === utils.MAX_VALUE_32BITS) {
this.compressedSize = extraReader.readInt(8);
this.compressedSize = extraReader.readLong(8);
}
if (this.localHeaderOffset === utils.MAX_VALUE_32BITS) {
this.localHeaderOffset = extraReader.readInt(8);
this.localHeaderOffset = extraReader.readLong(8);
}
if (this.diskNumberStart === utils.MAX_VALUE_32BITS) {
this.diskNumberStart = extraReader.readInt(4);
Expand Down