From 151045270d78b226b79d517ab36848556b1fc19e Mon Sep 17 00:00:00 2001 From: 5saviahv <5saviahv@users.noreply.github.com> Date: Mon, 24 May 2021 20:26:21 +0300 Subject: [PATCH] set UTF8 as default --- headers/entryHeader.js | 6 +++++- util/constants.js | 31 +++++++++++++++++++------------ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/headers/entryHeader.js b/headers/entryHeader.js index f1e3bba..eced450 100644 --- a/headers/entryHeader.js +++ b/headers/entryHeader.js @@ -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, @@ -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) { diff --git a/util/constants.js b/util/constants.js index 64739f4..119954b 100644 --- a/util/constants.js +++ b/util/constants.js @@ -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 */