Skip to content

Commit 0313c5e

Browse files
committed
use Version Needed = 4.5 only when ZIP64 is required. closes #24
1 parent ad55990 commit 0313c5e

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

index.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ function getEndOfCentralDirectoryRecord(self, actuallyJustTellMeHowLongItWouldBe
309309
// version made by 2 bytes
310310
zip64EocdrBuffer.writeUInt16LE(VERSION_MADE_BY, 12);
311311
// version needed to extract 2 bytes
312-
zip64EocdrBuffer.writeUInt16LE(VERSION_NEEDED_TO_EXTRACT, 14);
312+
zip64EocdrBuffer.writeUInt16LE(VERSION_NEEDED_TO_EXTRACT_ZIP64, 14);
313313
// number of this disk 4 bytes
314314
zip64EocdrBuffer.writeUInt32LE(0, 16);
315315
// number of the disk with the start of the central directory 4 bytes
@@ -421,8 +421,8 @@ Entry.prototype.useZip64Format = function() {
421421
);
422422
}
423423
var LOCAL_FILE_HEADER_FIXED_SIZE = 30;
424-
// this version enables zip64
425-
var VERSION_NEEDED_TO_EXTRACT = 45;
424+
var VERSION_NEEDED_TO_EXTRACT_UTF8 = 20;
425+
var VERSION_NEEDED_TO_EXTRACT_ZIP64 = 45;
426426
// 3 = unix. 63 = spec version 6.3
427427
var VERSION_MADE_BY = (3 << 8) | 63;
428428
var FILE_NAME_IS_UTF8 = 1 << 11;
@@ -444,7 +444,7 @@ Entry.prototype.getLocalFileHeader = function() {
444444
// local file header signature 4 bytes (0x04034b50)
445445
fixedSizeStuff.writeUInt32LE(0x04034b50, 0);
446446
// version needed to extract 2 bytes
447-
fixedSizeStuff.writeUInt16LE(VERSION_NEEDED_TO_EXTRACT, 4);
447+
fixedSizeStuff.writeUInt16LE(VERSION_NEEDED_TO_EXTRACT_UTF8, 4);
448448
// general purpose bit flag 2 bytes
449449
fixedSizeStuff.writeUInt16LE(generalPurposeBitFlag, 6);
450450
// compression method 2 bytes
@@ -513,11 +513,13 @@ Entry.prototype.getCentralDirectoryRecord = function() {
513513
var normalCompressedSize = this.compressedSize;
514514
var normalUncompressedSize = this.uncompressedSize;
515515
var normalRelativeOffsetOfLocalHeader = this.relativeOffsetOfLocalHeader;
516+
var versionNeededToExtract;
516517
var zeiefBuffer;
517518
if (this.useZip64Format()) {
518519
normalCompressedSize = 0xffffffff;
519520
normalUncompressedSize = 0xffffffff;
520521
normalRelativeOffsetOfLocalHeader = 0xffffffff;
522+
versionNeededToExtract = VERSION_NEEDED_TO_EXTRACT_ZIP64;
521523

522524
// ZIP64 extended information extra field
523525
zeiefBuffer = new Buffer(ZIP64_EXTENDED_INFORMATION_EXTRA_FIELD_SIZE);
@@ -534,6 +536,7 @@ Entry.prototype.getCentralDirectoryRecord = function() {
534536
// Disk Start Number 4 bytes Number of the disk on which this file starts
535537
// (omit)
536538
} else {
539+
versionNeededToExtract = VERSION_NEEDED_TO_EXTRACT_UTF8;
537540
zeiefBuffer = new Buffer(0);
538541
}
539542

@@ -542,7 +545,7 @@ Entry.prototype.getCentralDirectoryRecord = function() {
542545
// version made by 2 bytes
543546
fixedSizeStuff.writeUInt16LE(VERSION_MADE_BY, 4);
544547
// version needed to extract 2 bytes
545-
fixedSizeStuff.writeUInt16LE(VERSION_NEEDED_TO_EXTRACT, 6);
548+
fixedSizeStuff.writeUInt16LE(versionNeededToExtract, 6);
546549
// general purpose bit flag 2 bytes
547550
fixedSizeStuff.writeUInt16LE(generalPurposeBitFlag, 8);
548551
// compression method 2 bytes

0 commit comments

Comments
 (0)