Skip to content

Commit

Permalink
Merge pull request #382 from 5saviahv/utf8
Browse files Browse the repository at this point in the history
set UTF8 as default
  • Loading branch information
5saviahv authored May 25, 2021
2 parents 775165d + 1510452 commit 4ae39fa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
6 changes: 5 additions & 1 deletion headers/entryHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var Utils = require("../util"),

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

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

// Set EFS flag since filename and comment fields are all by default encoded using UTF-8.
// Without it file names may be corrupted for other apps when file names use unicode chars
_flags |= Constants.FLG_EFS;

var _dataHeader = {};

function setTime(val) {
Expand Down
31 changes: 19 additions & 12 deletions util/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,26 +75,33 @@ module.exports = {
REDUCED3 : 4, // reduced with compression factor 3
REDUCED4 : 5, // reduced with compression factor 4
IMPLODED : 6, // imploded
// 7 reserved
// 7 reserved for Tokenizing compression algorithm
DEFLATED : 8, // deflated
ENHANCED_DEFLATED: 9, // enhanced deflated
PKWARE : 10,// PKWare DCL imploded
// 11 reserved
// 11 reserved by PKWARE
BZIP2 : 12, // compressed using BZIP2
// 13 reserved
// 13 reserved by PKWARE
LZMA : 14, // LZMA
// 15-17 reserved
// 15-17 reserved by PKWARE
IBM_TERSE : 18, // compressed using IBM TERSE
IBM_LZ77 : 19, //IBM LZ77 z
IBM_LZ77 : 19, // IBM LZ77 z
AES_ENCRYPT : 99, // WinZIP AES encryption method

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

/* Load type */
Expand Down

0 comments on commit 4ae39fa

Please sign in to comment.