Skip to content

Commit 4ae39fa

Browse files
authored
Merge pull request #382 from 5saviahv/utf8
set UTF8 as default
2 parents 775165d + 1510452 commit 4ae39fa

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

headers/entryHeader.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var Utils = require("../util"),
33

44
/* The central directory file header */
55
module.exports = function () {
6-
var _verMade = 0x14, // v2.0
6+
var _verMade = 20, // v2.0
77
_version = 10, // v1.0
88
_flags = 0,
99
_method = 0,
@@ -21,6 +21,10 @@ module.exports = function () {
2121

2222
_verMade |= Utils.isWin ? 0x0a00 : 0x0300;
2323

24+
// Set EFS flag since filename and comment fields are all by default encoded using UTF-8.
25+
// Without it file names may be corrupted for other apps when file names use unicode chars
26+
_flags |= Constants.FLG_EFS;
27+
2428
var _dataHeader = {};
2529

2630
function setTime(val) {

util/constants.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,26 +75,33 @@ module.exports = {
7575
REDUCED3 : 4, // reduced with compression factor 3
7676
REDUCED4 : 5, // reduced with compression factor 4
7777
IMPLODED : 6, // imploded
78-
// 7 reserved
78+
// 7 reserved for Tokenizing compression algorithm
7979
DEFLATED : 8, // deflated
8080
ENHANCED_DEFLATED: 9, // enhanced deflated
8181
PKWARE : 10,// PKWare DCL imploded
82-
// 11 reserved
82+
// 11 reserved by PKWARE
8383
BZIP2 : 12, // compressed using BZIP2
84-
// 13 reserved
84+
// 13 reserved by PKWARE
8585
LZMA : 14, // LZMA
86-
// 15-17 reserved
86+
// 15-17 reserved by PKWARE
8787
IBM_TERSE : 18, // compressed using IBM TERSE
88-
IBM_LZ77 : 19, //IBM LZ77 z
88+
IBM_LZ77 : 19, // IBM LZ77 z
89+
AES_ENCRYPT : 99, // WinZIP AES encryption method
8990

9091
/* General purpose bit flag */
91-
FLG_ENC : 0, // encripted file
92-
FLG_COMP1 : 1, // compression option
93-
FLG_COMP2 : 2, // compression option
94-
FLG_DESC : 4, // data descriptor
95-
FLG_ENH : 8, // enhanced deflation
96-
FLG_STR : 16, // strong encryption
97-
FLG_LNG : 1024, // language encoding
92+
// values can obtained with expression 2**bitnr
93+
FLG_ENC : 1, // Bit 0: encrypted file
94+
FLG_COMP1 : 2, // Bit 1, compression option
95+
FLG_COMP2 : 4, // Bit 2, compression option
96+
FLG_DESC : 8, // Bit 3, data descriptor
97+
FLG_ENH : 16, // Bit 4, enhanced deflating
98+
FLG_PATCH : 32, // Bit 5, indicates that the file is compressed patched data.
99+
FLG_STR : 64, // Bit 6, strong encryption (patented)
100+
// Bits 7-10: Currently unused.
101+
FLG_EFS : 2048, // Bit 11: Language encoding flag (EFS)
102+
// Bit 12: Reserved by PKWARE for enhanced compression.
103+
// Bit 13: encrypted the Central Directory (patented).
104+
// Bits 14-15: Reserved by PKWARE.
98105
FLG_MSK : 4096, // mask header values
99106

100107
/* Load type */

0 commit comments

Comments
 (0)