|
32 | 32 | import { |
33 | 33 | MAX_32_BITS, |
34 | 34 | MAX_16_BITS, |
| 35 | + MAX_8_BITS, |
35 | 36 | COMPRESSION_METHOD_DEFLATE, |
36 | 37 | COMPRESSION_METHOD_STORE, |
37 | 38 | COMPRESSION_METHOD_AES, |
@@ -142,6 +143,7 @@ const ERR_UNSUPPORTED_COMPRESSION = "Compression method not supported"; |
142 | 143 | const ERR_SPLIT_ZIP_FILE = "Split zip file"; |
143 | 144 | const ERR_OVERLAPPING_ENTRY = "Overlapping entry found"; |
144 | 145 | const CHARSET_UTF8 = "utf-8"; |
| 146 | +const PROPERTY_NAME_UTF8_SUFFIX = "UTF8"; |
145 | 147 | const CHARSET_CP437 = "cp437"; |
146 | 148 | const ZIP64_PROPERTIES = [ |
147 | 149 | [PROPERTY_NAME_UNCOMPRESSED_SIZE, MAX_32_BITS], |
@@ -534,7 +536,7 @@ class ZipEntry { |
534 | 536 | zipCrypto, |
535 | 537 | encryptionStrength: extraFieldAES && extraFieldAES.strength, |
536 | 538 | signed: getOptionValue(zipEntry, options, OPTION_CHECK_SIGNATURE) && !passThrough, |
537 | | - passwordVerification: zipCrypto && (dataDescriptor ? ((rawLastModDate >>> 8) & 0xFF) : ((signature >>> 24) & 0xFF)), |
| 539 | + passwordVerification: zipCrypto && (dataDescriptor ? ((rawLastModDate >>> 8) & MAX_8_BITS) : ((signature >>> 24) & MAX_8_BITS)), |
538 | 540 | outputSize: passThrough ? compressedSize : uncompressedSize, |
539 | 541 | signature, |
540 | 542 | compressed: compressionMethod != 0 && !passThrough, |
@@ -706,7 +708,7 @@ function readExtraFieldUnicode(extraFieldUnicode, propertyName, rawPropertyName, |
706 | 708 | }); |
707 | 709 | if (extraFieldUnicode.valid) { |
708 | 710 | directory[propertyName] = extraFieldUnicode[propertyName]; |
709 | | - directory[propertyName + "UTF8"] = true; |
| 711 | + directory[propertyName + PROPERTY_NAME_UTF8_SUFFIX] = true; |
710 | 712 | } |
711 | 713 | } |
712 | 714 |
|
@@ -888,7 +890,7 @@ function getOptionValue(zipReader, options, name) { |
888 | 890 | } |
889 | 891 |
|
890 | 892 | function getDate(timeRaw) { |
891 | | - const date = (timeRaw & 0xffff0000) >> 16, time = timeRaw & 0x0000ffff; |
| 893 | + const date = (timeRaw & 0xffff0000) >> 16, time = timeRaw & MAX_16_BITS; |
892 | 894 | try { |
893 | 895 | return new Date(1980 + ((date & 0xFE00) >> 9), ((date & 0x01E0) >> 5) - 1, date & 0x001F, (time & 0xF800) >> 11, (time & 0x07E0) >> 5, (time & 0x001F) * 2, 0); |
894 | 896 | } catch { |
|
0 commit comments