36
36
import net .lingala .zip4j .model .enums .CompressionLevel ;
37
37
import net .lingala .zip4j .model .enums .EncryptionMethod ;
38
38
import net .lingala .zip4j .model .enums .AesKeyStrength ;
39
+ import net .lingala .zip4j .progress .ProgressMonitor ;
39
40
40
41
import java .nio .charset .Charset ;
41
42
@@ -67,7 +68,7 @@ public void isPasswordProtected(final String zipFilePath, final Promise promise)
67
68
68
69
@ ReactMethod
69
70
public void unzipWithPassword (final String zipFilePath , final String destDirectory ,
70
- final String password , final Promise promise ) {
71
+ final String password , final Promise promise ) {
71
72
new Thread (new Runnable () {
72
73
@ Override
73
74
public void run () {
@@ -92,11 +93,11 @@ public void run() {
92
93
String destDirCanonicalPath = (new File (destDirectory ).getCanonicalPath ()) + File .separator ;
93
94
94
95
if (!canonicalPath .startsWith (destDirCanonicalPath )) {
95
- throw new SecurityException (String .format ("Found Zip Path Traversal Vulnerability with %s" , canonicalPath ));
96
+ throw new SecurityException (String .format ("Found Zip Path Traversal Vulnerability with %s" , canonicalPath ));
96
97
}
97
98
98
99
if (!fileHeader .isDirectory ()) {
99
- zipFile .extractFile (fileHeader , destDirectory );
100
+ zipFile .extractFile (fileHeader , destDirectory );
100
101
extractedFileNames .add (fileHeader .getFileName ());
101
102
}
102
103
updateProgress (i + 1 , totalFiles , zipFilePath );
@@ -237,7 +238,7 @@ public void run() {
237
238
String destDirCanonicalPath = (new File (destDirectory ).getCanonicalPath ()) + File .separator ;
238
239
239
240
if (!canonicalPath .startsWith (destDirCanonicalPath )) {
240
- throw new SecurityException (String .format ("Found Zip Path Traversal Vulnerability with %s" , canonicalPath ));
241
+ throw new SecurityException (String .format ("Found Zip Path Traversal Vulnerability with %s" , canonicalPath ));
241
242
}
242
243
243
244
if (!fout .exists ()) {
@@ -300,21 +301,21 @@ public void zipFolder(final String folder, final String destFile, final Promise
300
301
301
302
@ ReactMethod
302
303
public void zipFilesWithPassword (final ReadableArray files , final String destFile , final String password ,
303
- String encryptionMethod , Promise promise ) {
304
+ String encryptionMethod , Promise promise ) {
304
305
zipWithPassword (files .toArrayList (), destFile , password , encryptionMethod , promise );
305
306
}
306
307
307
308
308
309
@ ReactMethod
309
310
public void zipFolderWithPassword (final String folder , final String destFile , final String password ,
310
- String encryptionMethod , Promise promise ) {
311
+ String encryptionMethod , Promise promise ) {
311
312
ArrayList <Object > folderAsArrayList = new ArrayList <>();
312
313
folderAsArrayList .add (folder );
313
314
zipWithPassword (folderAsArrayList , destFile , password , encryptionMethod , promise );
314
315
}
315
316
316
317
private void zipWithPassword (final ArrayList <Object > filesOrDirectory , final String destFile , final String password ,
317
- String encryptionMethod , Promise promise ) {
318
+ String encryptionMethod , Promise promise ) {
318
319
try {
319
320
320
321
ZipParameters parameters = new ZipParameters ();
0 commit comments