[Git][java-team/zip4j][master] 3 commits: New upstream version 2.11.5
Andrius Merkys (@merkys)
gitlab at salsa.debian.org
Fri Feb 24 15:01:03 GMT 2023
Andrius Merkys pushed to branch master at Debian Java Maintainers / zip4j
Commits:
4ed3ffe0 by Andrius Merkys at 2023-02-24T08:45:25-05:00
New upstream version 2.11.5
- - - - -
f673d0ba by Andrius Merkys at 2023-02-24T08:45:40-05:00
Update upstream source from tag 'upstream/2.11.5'
Update to upstream version '2.11.5'
with Debian dir 9f3a8d765344501e581023fc8ceb09ee7472ea93
- - - - -
24f6e7e3 by Andrius Merkys at 2023-02-24T08:46:37-05:00
Update changelog for 2.11.5-1 release
- - - - -
10 changed files:
- + NOTICE
- README.md
- debian/changelog
- pom.xml
- src/main/java/net/lingala/zip4j/headers/HeaderReader.java
- src/main/java/net/lingala/zip4j/tasks/AbstractExtractFileTask.java
- src/main/java/net/lingala/zip4j/util/FileUtils.java
- src/test/java/net/lingala/zip4j/AddFilesToZipIT.java
- src/test/java/net/lingala/zip4j/ExtractZipFileIT.java
- + src/test/resources/test-archives/zipWithLinkToDirAndFolder.zip
Changes:
=====================================
NOTICE
=====================================
@@ -0,0 +1,2 @@
+Zip4j
+Copyright 2019 and onwards Srikanth Reddy Lingala
\ No newline at end of file
=====================================
README.md
=====================================
@@ -71,7 +71,7 @@ Zip4j supports JDK 7 as well. In cases where the feature/class from JDK 8 is mis
<dependency>
<groupId>net.lingala.zip4j</groupId>
<artifactId>zip4j</artifactId>
- <version>2.11.3</version>
+ <version>2.11.5-SNAPSHOT</version>
</dependency>
```
=====================================
debian/changelog
=====================================
@@ -1,3 +1,9 @@
+zip4j (2.11.5-1) unstable; urgency=medium
+
+ * New upstream version 2.11.5
+
+ -- Andrius Merkys <merkys at debian.org> Fri, 24 Feb 2023 08:46:32 -0500
+
zip4j (2.11.3-1) unstable; urgency=medium
* New upstream version 2.11.3
=====================================
pom.xml
=====================================
@@ -6,7 +6,7 @@
<groupId>net.lingala.zip4j</groupId>
<artifactId>zip4j</artifactId>
- <version>2.11.4-SNAPSHOT</version>
+ <version>2.11.4</version>
<name>Zip4j</name>
<description>Zip4j - A Java library for zip files and streams</description>
=====================================
src/main/java/net/lingala/zip4j/headers/HeaderReader.java
=====================================
@@ -66,6 +66,10 @@ public class HeaderReader {
public ZipModel readAllHeaders(RandomAccessFile zip4jRaf, Zip4jConfig zip4jConfig) throws IOException {
+ if (zip4jRaf.length() == 0) {
+ return new ZipModel();
+ }
+
if (zip4jRaf.length() < ENDHDR) {
throw new ZipException("Zip file size less than minimum expected zip file size. " +
"Probably not a zip file or a corrupted zip file");
=====================================
src/main/java/net/lingala/zip4j/tasks/AbstractExtractFileTask.java
=====================================
@@ -59,14 +59,16 @@ public abstract class AbstractExtractFileTask<T> extends AsyncZipTask<T> {
throw new ZipException("Could not create directory: " + outputFile);
}
}
- } else if (isSymbolicLink(fileHeader)) {
+ } else if (isSymbolicLink) {
createSymLink(zipInputStream, fileHeader, outputFile, progressMonitor);
} else {
checkOutputDirectoryStructure(outputFile);
unzipFile(zipInputStream, outputFile, progressMonitor, readBuff);
}
- UnzipUtil.applyFileAttributes(fileHeader, outputFile);
+ if (!isSymbolicLink) {
+ UnzipUtil.applyFileAttributes(fileHeader, outputFile);
+ }
}
private void assertCanonicalPathsAreSame(File outputFile, String outputPath, FileHeader fileHeader)
@@ -128,6 +130,11 @@ public abstract class AbstractExtractFileTask<T> extends AsyncZipTask<T> {
try {
Path linkTarget = Paths.get(symLinkPath);
+ if (outputFile.exists()) {
+ if (!outputFile.delete()) {
+ throw new ZipException("Could not delete existing symlink " + outputFile);
+ }
+ }
Files.createSymbolicLink(outputFile.toPath(), linkTarget);
} catch (NoSuchMethodError error) {
try (OutputStream outputStream = new FileOutputStream(outputFile)) {
=====================================
src/main/java/net/lingala/zip4j/util/FileUtils.java
=====================================
@@ -222,7 +222,7 @@ public class FileUtils {
String rootPath = new File(fileToAdd.getParentFile().getCanonicalFile().getPath() + File.separator + fileToAdd.getCanonicalFile().getName()).getPath();
tmpFileName = rootPath.substring(rootFolderFileRef.length());
} else {
- if (!fileToAdd.getCanonicalFile().toPath().startsWith(rootFolderFileRef)) {
+ if (!fileToAdd.getCanonicalFile().getPath().startsWith(rootFolderFileRef)) {
tmpFileName = fileToAdd.getCanonicalFile().getParentFile().getName() + FILE_SEPARATOR + fileToAdd.getCanonicalFile().getName();
} else {
tmpFileName = fileCanonicalPath.substring(rootFolderFileRef.length());
@@ -558,9 +558,17 @@ public class FileUtils {
LinkOption.NOFOLLOW_LINKS);
Set<PosixFilePermission> posixFilePermissions = posixFileAttributeView.readAttributes().permissions();
- fileAttributes[3] = setBitIfApplicable(Files.isRegularFile(file), fileAttributes[3], 7);
- fileAttributes[3] = setBitIfApplicable(Files.isDirectory(file), fileAttributes[3], 6);
- fileAttributes[3] = setBitIfApplicable(Files.isSymbolicLink(file), fileAttributes[3], 5);
+ boolean isSymlink = Files.isSymbolicLink(file);
+ if (isSymlink) {
+ // Mark as a regular file and not a directory if file is a symlink and even if the symlink points to a directory
+ fileAttributes[3] = BitUtils.setBit(fileAttributes[3], 7);
+ fileAttributes[3] = BitUtils.unsetBit(fileAttributes[3], 6);
+ } else {
+ fileAttributes[3] = setBitIfApplicable(Files.isRegularFile(file), fileAttributes[3], 7);
+ fileAttributes[3] = setBitIfApplicable(Files.isDirectory(file), fileAttributes[3], 6);
+ }
+
+ fileAttributes[3] = setBitIfApplicable(isSymlink, fileAttributes[3], 5);
fileAttributes[3] = setBitIfApplicable(posixFilePermissions.contains(OWNER_READ), fileAttributes[3], 0);
fileAttributes[2] = setBitIfApplicable(posixFilePermissions.contains(OWNER_WRITE), fileAttributes[2], 7);
fileAttributes[2] = setBitIfApplicable(posixFilePermissions.contains(OWNER_EXECUTE), fileAttributes[2], 6);
=====================================
src/test/java/net/lingala/zip4j/AddFilesToZipIT.java
=====================================
@@ -949,6 +949,22 @@ public class AddFilesToZipIT extends AbstractIT {
extractZipFileWithStream(generatedZipFile, PASSWORD);
}
+ @Test
+ public void testAddStreamToAnEmptyFileDoesNotThrowException() throws IOException {
+ if (!generatedZipFile.createNewFile()) {
+ throw new RuntimeException("Cannot create an empty file to test");
+ }
+ File fileToAdd = TestUtils.getTestFileFromResources("sample.pdf");
+ try (ZipFile zipFile = new ZipFile(generatedZipFile);
+ InputStream inputStream = Files.newInputStream(fileToAdd.toPath())) {
+ ZipParameters zipParameters = new ZipParameters();
+ zipParameters.setFileNameInZip(fileToAdd.getName());
+ zipFile.addStream(inputStream, zipParameters);
+ }
+
+ ZipFileVerifier.verifyZipFileByExtractingAllFiles(generatedZipFile, outputFolder, 1);
+ }
+
@Test
public void testAddFolderWithCustomBufferSize() throws IOException {
ZipFile zipFile = new ZipFile(generatedZipFile);
=====================================
src/test/java/net/lingala/zip4j/ExtractZipFileIT.java
=====================================
@@ -19,6 +19,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
+import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
@@ -328,6 +329,22 @@ public class ExtractZipFileIT extends AbstractIT {
assertThat(outputFolder.listFiles()[0].getName()).isEqualTo(newFileName);
}
+ @Test
+ public void testSymlinkToDirectoryMaintainsSymlink() throws IOException {
+ verifyZipFileByExtractingAllFiles(getTestArchiveFromResources("zipWithLinkToDirAndFolder.zip"), null, outputFolder, 5, false);
+
+ Path aDirectory = Paths.get(outputFolder.getPath(), "a");
+ Path symlinkToDir = Paths.get(outputFolder.getPath(), "b");
+ Path aFile = Paths.get(outputFolder.getPath(), "c");
+ Path symlinkToFile = Paths.get(outputFolder.getPath(), "d");
+ assertThat(aDirectory).isDirectory();
+ assertThat(Files.isSymbolicLink(symlinkToDir)).isTrue();
+ assertThat(aFile).isRegularFile();
+ assertThat(symlinkToFile).isSymbolicLink();
+ assertThat(Files.readSymbolicLink(symlinkToDir)).isEqualTo(aDirectory.getFileName());
+ assertThat(Files.readSymbolicLink(symlinkToFile)).isEqualTo(aFile.getFileName());
+ }
+
@Test
public void testExtractFilesThrowsExceptionForWrongPasswordForAes() throws IOException {
ZipParameters zipParameters = createZipParameters(EncryptionMethod.AES, AesKeyStrength.KEY_STRENGTH_256);
=====================================
src/test/resources/test-archives/zipWithLinkToDirAndFolder.zip
=====================================
Binary files /dev/null and b/src/test/resources/test-archives/zipWithLinkToDirAndFolder.zip differ
View it on GitLab: https://salsa.debian.org/java-team/zip4j/-/compare/d3eba6591630c9af54c0731835072ee2bc1386bf...24f6e7e32ef8202a2698844d57d28097ab85fb2e
--
View it on GitLab: https://salsa.debian.org/java-team/zip4j/-/compare/d3eba6591630c9af54c0731835072ee2bc1386bf...24f6e7e32ef8202a2698844d57d28097ab85fb2e
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20230224/1a1fc9fc/attachment.htm>
More information about the pkg-java-commits
mailing list