@onekeyfe/react-native-zip-archive 6.7.0-1 → 6.7.0-alpha.324
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -18,10 +18,28 @@ final class ReactNativeZipArchive: HybridReactNativeZipArchiveSpec {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
private static let maxUncompressedBytes: UInt64 = 512 * 1024 * 1024
|
|
22
|
+
|
|
23
|
+
private static func validateArchivePayloadSize(atPath path: String) throws {
|
|
24
|
+
var sizeError: NSError?
|
|
25
|
+
let payloadSize = SSZipArchive.payloadSizeForArchive(atPath: path, error: &sizeError)
|
|
26
|
+
if let sizeError {
|
|
27
|
+
throw sizeError
|
|
28
|
+
}
|
|
29
|
+
if payloadSize.uint64Value > maxUncompressedBytes {
|
|
30
|
+
throw NSError(
|
|
31
|
+
domain: "ZipArchive",
|
|
32
|
+
code: -1,
|
|
33
|
+
userInfo: [NSLocalizedDescriptionKey: "Archive uncompressed size exceeds maximum allowed (512 MB)"]
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
21
38
|
// MARK: - unzip
|
|
22
39
|
|
|
23
40
|
func unzip(from: String, to: String) throws -> Promise<String> {
|
|
24
41
|
return Promise.async {
|
|
42
|
+
try Self.validateArchivePayloadSize(atPath: from)
|
|
25
43
|
var error: NSError?
|
|
26
44
|
let success = SSZipArchive.unzipFile(
|
|
27
45
|
atPath: from,
|
|
@@ -52,6 +70,7 @@ final class ReactNativeZipArchive: HybridReactNativeZipArchiveSpec {
|
|
|
52
70
|
|
|
53
71
|
func unzipWithPassword(from: String, to: String, password: String) throws -> Promise<String> {
|
|
54
72
|
return Promise.async {
|
|
73
|
+
try Self.validateArchivePayloadSize(atPath: from)
|
|
55
74
|
var error: NSError?
|
|
56
75
|
let success = SSZipArchive.unzipFile(
|
|
57
76
|
atPath: from,
|
package/package.json
CHANGED