[Git][java-team/zip4j][master] 3 commits: New upstream version 2.11.2
Andrius Merkys (@merkys)
gitlab at salsa.debian.org
Fri Sep 16 07:36:48 BST 2022
Andrius Merkys pushed to branch master at Debian Java Maintainers / zip4j
Commits:
388fc2da by Andrius Merkys at 2022-09-16T01:40:10-04:00
New upstream version 2.11.2
- - - - -
c9fcb839 by Andrius Merkys at 2022-09-16T01:40:16-04:00
Update upstream source from tag 'upstream/2.11.2'
Update to upstream version '2.11.2'
with Debian dir 6b5911719e8cbd1b9f89132421e8b6660b24554b
- - - - -
08390db3 by Andrius Merkys at 2022-09-16T01:41:11-04:00
Update changelog for 2.11.2-1 release
- - - - -
23 changed files:
- .github/workflows/maven.yml
- README.md
- debian/changelog
- pom.xml
- src/main/java/net/lingala/zip4j/headers/HeaderWriter.java
- src/main/java/net/lingala/zip4j/io/inputstream/DecompressedInputStream.java
- src/main/java/net/lingala/zip4j/io/inputstream/InflaterInputStream.java
- src/main/java/net/lingala/zip4j/io/inputstream/NoCipherInputStream.java
- src/main/java/net/lingala/zip4j/io/inputstream/StoreInputStream.java
- src/main/java/net/lingala/zip4j/io/inputstream/ZipInputStream.java
- src/main/java/net/lingala/zip4j/io/outputstream/CompressedOutputStream.java
- src/main/java/net/lingala/zip4j/io/outputstream/DeflaterOutputStream.java
- src/main/java/net/lingala/zip4j/io/outputstream/StoreOutputStream.java
- src/main/java/net/lingala/zip4j/io/outputstream/ZipOutputStream.java
- src/main/java/net/lingala/zip4j/model/ZipParameters.java
- src/main/java/net/lingala/zip4j/tasks/AbstractExtractFileTask.java
- src/main/java/net/lingala/zip4j/tasks/AbstractModifyFileTask.java
- src/main/java/net/lingala/zip4j/util/FileUtils.java
- src/test/java/net/lingala/zip4j/ZipFileZip64IT.java
- src/test/java/net/lingala/zip4j/io/inputstream/ZipInputStreamIT.java
- src/test/java/net/lingala/zip4j/io/outputstream/ZipOutputStreamIT.java
- src/test/java/net/lingala/zip4j/testutils/RandomInputStream.java
- src/test/java/net/lingala/zip4j/testutils/SlowTests.java → src/test/java/net/lingala/zip4j/testutils/SlowTest.java
Changes:
=====================================
.github/workflows/maven.yml
=====================================
@@ -7,10 +7,9 @@ on:
branches: [ master ]
jobs:
- build:
-
+ test-on-ubuntu:
+ name: Run zip4j tests on ubuntu
runs-on: ubuntu-latest
-
steps:
- uses: actions/checkout at v2
- name: Set up JDK 11
@@ -21,3 +20,17 @@ jobs:
cache: maven
- name: Build with Maven
run: mvn -B clean verify --file pom.xml
+ test-on-windows:
+ name: Run zip4j tests on Windows
+ runs-on: windows-latest
+ if: ${{ false }}
+ steps:
+ - uses: actions/checkout at v2
+ - name: Set up JDK 11
+ uses: actions/setup-java at v2
+ with:
+ java-version: '11'
+ distribution: 'temurin'
+ cache: maven
+ - name: Build with Maven
+ run: mvn -B -Pskip-slow-tests clean verify --file pom.xml
=====================================
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.0</version>
+ <version>2.11.2</version>
</dependency>
```
@@ -336,7 +336,7 @@ Map<String, String> fileNamesMap = new HashMap<>();
fileNamesMap.put("firstFile.txt", "newFileFirst.txt");
fileNamesMap.put("secondFile.pdf", "newSecondFile.pdf");
fileNamesMap.put("some-folder/thirdFile.bin", "some-folder/newThirdFile.bin");
-new ZipFile("filename.zip").renameFile("entry-to-be-changed.pdf", "new-file-name.pdf");
+new ZipFile("filename.zip").renameFiles(fileNamesMap);
```
To modify an entry name which is inside a folder, the new file name should contain the complete parent path as well.
=====================================
debian/changelog
=====================================
@@ -1,3 +1,9 @@
+zip4j (2.11.2-1) unstable; urgency=medium
+
+ * New upstream version 2.11.2
+
+ -- Andrius Merkys <merkys at debian.org> Fri, 16 Sep 2022 01:41:08 -0400
+
zip4j (2.11.1-1) unstable; urgency=medium
* New upstream version 2.11.1
=====================================
pom.xml
=====================================
@@ -6,7 +6,7 @@
<groupId>net.lingala.zip4j</groupId>
<artifactId>zip4j</artifactId>
- <version>2.11.1-SNAPSHOT</version>
+ <version>2.11.2</version>
<name>Zip4j</name>
<description>Zip4j - A Java library for zip files and streams</description>
@@ -36,6 +36,7 @@
<assertj.version>2.9.1</assertj.version>
<mockito.version>2.28.2</mockito.version>
<powermock.version>2.0.2</powermock.version>
+ <failsafe.plugin.version>3.0.0-M3</failsafe.plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
@@ -93,6 +94,29 @@
<additionalparam>-Xdoclint:none</additionalparam>
</properties>
</profile>
+ <profile>
+ <id>skip-slow-tests</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <version>${failsafe.plugin.version}</version>
+ <executions>
+ <execution>
+ <configuration>
+ <excludedGroups>net.lingala.zip4j.testutils.SlowTest</excludedGroups>
+ </configuration>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
<build>
@@ -109,7 +133,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
- <version>3.0.0-M3</version>
+ <version>${failsafe.plugin.version}</version>
<executions>
<execution>
<goals>
=====================================
src/main/java/net/lingala/zip4j/headers/HeaderWriter.java
=====================================
@@ -127,7 +127,7 @@ public class HeaderWriter {
rawIO.writeShortLittleEndian(byteArrayOutputStream, (int) aesExtraDataRecord.getSignature().getValue());
rawIO.writeShortLittleEndian(byteArrayOutputStream, aesExtraDataRecord.getDataSize());
rawIO.writeShortLittleEndian(byteArrayOutputStream, aesExtraDataRecord.getAesVersion().getVersionNumber());
- byteArrayOutputStream.write(aesExtraDataRecord.getVendorID().getBytes());
+ byteArrayOutputStream.write(getBytesFromString(aesExtraDataRecord.getVendorID(), charset));
byte[] aesStrengthBytes = new byte[1];
aesStrengthBytes[0] = (byte) aesExtraDataRecord.getAesKeyStrength().getRawCode();
@@ -221,7 +221,7 @@ public class HeaderWriter {
}
try(ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
- long offsetCentralDir = zipModel.getEndOfCentralDirectoryRecord().getOffsetOfStartOfCentralDirectory();
+ long offsetCentralDir = getOffsetOfCentralDirectory(zipModel);
writeCentralDirectory(zipModel, byteArrayOutputStream, rawIO, charset);
int sizeOfCentralDir = byteArrayOutputStream.size();
@@ -496,7 +496,7 @@ public class HeaderWriter {
rawIO.writeShortLittleEndian(byteArrayOutputStream, (int) aesExtraDataRecord.getSignature().getValue());
rawIO.writeShortLittleEndian(byteArrayOutputStream, aesExtraDataRecord.getDataSize());
rawIO.writeShortLittleEndian(byteArrayOutputStream, aesExtraDataRecord.getAesVersion().getVersionNumber());
- byteArrayOutputStream.write(aesExtraDataRecord.getVendorID().getBytes());
+ byteArrayOutputStream.write(getBytesFromString(aesExtraDataRecord.getVendorID(), charset));
byte[] aesStrengthBytes = new byte[1];
aesStrengthBytes[0] = (byte) aesExtraDataRecord.getAesKeyStrength().getRawCode();
=====================================
src/main/java/net/lingala/zip4j/io/inputstream/DecompressedInputStream.java
=====================================
@@ -6,10 +6,10 @@ import java.io.PushbackInputStream;
abstract class DecompressedInputStream extends InputStream {
- private CipherInputStream cipherInputStream;
+ private CipherInputStream<?> cipherInputStream;
protected byte[] oneByteBuffer = new byte[1];
- public DecompressedInputStream(CipherInputStream cipherInputStream) {
+ public DecompressedInputStream(CipherInputStream<?> cipherInputStream) {
this.cipherInputStream = cipherInputStream;
}
=====================================
src/main/java/net/lingala/zip4j/io/inputstream/InflaterInputStream.java
=====================================
@@ -14,7 +14,7 @@ public class InflaterInputStream extends DecompressedInputStream {
private byte[] singleByteBuffer = new byte[1];
private int len;
- public InflaterInputStream(CipherInputStream cipherInputStream, int bufferSize) {
+ public InflaterInputStream(CipherInputStream<?> cipherInputStream, int bufferSize) {
super(cipherInputStream);
this.inflater = new Inflater(true);
buff = new byte[bufferSize];
=====================================
src/main/java/net/lingala/zip4j/io/inputstream/NoCipherInputStream.java
=====================================
@@ -5,7 +5,7 @@ import net.lingala.zip4j.model.LocalFileHeader;
import java.io.IOException;
-class NoCipherInputStream extends CipherInputStream {
+class NoCipherInputStream extends CipherInputStream<NoCipherInputStream.NoDecrypter> {
public NoCipherInputStream(ZipEntryInputStream zipEntryInputStream, LocalFileHeader localFileHeader,
char[] password, int bufferSize) throws IOException {
@@ -13,7 +13,7 @@ class NoCipherInputStream extends CipherInputStream {
}
@Override
- protected Decrypter initializeDecrypter(LocalFileHeader localFileHeader, char[] password, boolean useUtf8ForPassword) {
+ protected NoDecrypter initializeDecrypter(LocalFileHeader localFileHeader, char[] password, boolean useUtf8ForPassword) {
return new NoDecrypter();
}
=====================================
src/main/java/net/lingala/zip4j/io/inputstream/StoreInputStream.java
=====================================
@@ -2,7 +2,7 @@ package net.lingala.zip4j.io.inputstream;
class StoreInputStream extends DecompressedInputStream {
- public StoreInputStream(CipherInputStream cipherInputStream) {
+ public StoreInputStream(CipherInputStream<?> cipherInputStream) {
super(cipherInputStream);
}
}
=====================================
src/main/java/net/lingala/zip4j/io/inputstream/ZipInputStream.java
=====================================
@@ -244,11 +244,11 @@ public class ZipInputStream extends InputStream {
private DecompressedInputStream initializeEntryInputStream(LocalFileHeader localFileHeader) throws IOException {
ZipEntryInputStream zipEntryInputStream = new ZipEntryInputStream(inputStream, getCompressedSize(localFileHeader));
- CipherInputStream cipherInputStream = initializeCipherInputStream(zipEntryInputStream, localFileHeader);
+ CipherInputStream<?> cipherInputStream = initializeCipherInputStream(zipEntryInputStream, localFileHeader);
return initializeDecompressorForThisEntry(cipherInputStream, localFileHeader);
}
- private CipherInputStream initializeCipherInputStream(ZipEntryInputStream zipEntryInputStream,
+ private CipherInputStream<?> initializeCipherInputStream(ZipEntryInputStream zipEntryInputStream,
LocalFileHeader localFileHeader) throws IOException {
if (!localFileHeader.isEncrypted()) {
return new NoCipherInputStream(zipEntryInputStream, localFileHeader, password, zip4jConfig.getBufferSize());
@@ -266,7 +266,7 @@ public class ZipInputStream extends InputStream {
}
}
- private DecompressedInputStream initializeDecompressorForThisEntry(CipherInputStream cipherInputStream,
+ private DecompressedInputStream initializeDecompressorForThisEntry(CipherInputStream<?> cipherInputStream,
LocalFileHeader localFileHeader) throws ZipException {
CompressionMethod compressionMethod = getCompressionMethod(localFileHeader);
=====================================
src/main/java/net/lingala/zip4j/io/outputstream/CompressedOutputStream.java
=====================================
@@ -5,9 +5,9 @@ import java.io.OutputStream;
abstract class CompressedOutputStream extends OutputStream {
- private CipherOutputStream cipherOutputStream;
+ private CipherOutputStream<?> cipherOutputStream;
- public CompressedOutputStream(CipherOutputStream cipherOutputStream) {
+ public CompressedOutputStream(CipherOutputStream<?> cipherOutputStream) {
this.cipherOutputStream = cipherOutputStream;
}
=====================================
src/main/java/net/lingala/zip4j/io/outputstream/DeflaterOutputStream.java
=====================================
@@ -26,7 +26,7 @@ class DeflaterOutputStream extends CompressedOutputStream {
private byte[] buff;
protected Deflater deflater;
- public DeflaterOutputStream(CipherOutputStream cipherOutputStream, CompressionLevel compressionLevel, int bufferSize) {
+ public DeflaterOutputStream(CipherOutputStream<?> cipherOutputStream, CompressionLevel compressionLevel, int bufferSize) {
super(cipherOutputStream);
deflater = new Deflater(compressionLevel.getLevel(), true);
buff = new byte[bufferSize];
=====================================
src/main/java/net/lingala/zip4j/io/outputstream/StoreOutputStream.java
=====================================
@@ -2,7 +2,7 @@ package net.lingala.zip4j.io.outputstream;
class StoreOutputStream extends CompressedOutputStream {
- public StoreOutputStream(CipherOutputStream cipherOutputStream) {
+ public StoreOutputStream(CipherOutputStream<?> cipherOutputStream) {
super(cipherOutputStream);
}
=====================================
src/main/java/net/lingala/zip4j/io/outputstream/ZipOutputStream.java
=====================================
@@ -78,18 +78,7 @@ public class ZipOutputStream extends OutputStream {
public void putNextEntry(ZipParameters zipParameters) throws IOException {
verifyZipParameters(zipParameters);
-
- ZipParameters clonedZipParameters = new ZipParameters(zipParameters);
- if (isZipEntryDirectory(zipParameters.getFileNameInZip())) {
- clonedZipParameters.setWriteExtendedLocalFileHeader(false);
- clonedZipParameters.setCompressionMethod(CompressionMethod.STORE);
- clonedZipParameters.setEncryptFiles(false);
- clonedZipParameters.setEntrySize(0);
-
- if (zipParameters.getLastModifiedFileTime() <= 0) {
- clonedZipParameters.setLastModifiedFileTime(System.currentTimeMillis());
- }
- }
+ ZipParameters clonedZipParameters = cloneAndPrepareZipParameters(zipParameters);
initializeAndWriteFileHeader(clonedZipParameters);
//Initialisation of below compressedOutputStream should happen after writing local file header
@@ -201,11 +190,11 @@ public class ZipOutputStream extends OutputStream {
private CompressedOutputStream initializeCompressedOutputStream(ZipParameters zipParameters) throws IOException {
ZipEntryOutputStream zipEntryOutputStream = new ZipEntryOutputStream(countingOutputStream);
- CipherOutputStream cipherOutputStream = initializeCipherOutputStream(zipEntryOutputStream, zipParameters);
+ CipherOutputStream<?> cipherOutputStream = initializeCipherOutputStream(zipEntryOutputStream, zipParameters);
return initializeCompressedOutputStream(cipherOutputStream, zipParameters);
}
- private CipherOutputStream initializeCipherOutputStream(ZipEntryOutputStream zipEntryOutputStream,
+ private CipherOutputStream<?> initializeCipherOutputStream(ZipEntryOutputStream zipEntryOutputStream,
ZipParameters zipParameters) throws IOException {
if (!zipParameters.isEncryptFiles()) {
return new NoCipherOutputStream(zipEntryOutputStream, zipParameters, null);
@@ -226,7 +215,7 @@ public class ZipOutputStream extends OutputStream {
}
}
- private CompressedOutputStream initializeCompressedOutputStream(CipherOutputStream cipherOutputStream,
+ private CompressedOutputStream initializeCompressedOutputStream(CipherOutputStream<?> cipherOutputStream,
ZipParameters zipParameters) {
if (zipParameters.getCompressionMethod() == CompressionMethod.DEFLATE) {
return new DeflaterOutputStream(cipherOutputStream, zipParameters.getCompressionLevel(), zip4jConfig.getBufferSize());
@@ -257,4 +246,21 @@ public class ZipOutputStream extends OutputStream {
return fileHeader.getAesExtraDataRecord().getAesVersion().equals(AesVersion.ONE);
}
+
+ private ZipParameters cloneAndPrepareZipParameters(ZipParameters zipParameters) {
+ ZipParameters clonedZipParameters = new ZipParameters(zipParameters);
+
+ if (isZipEntryDirectory(zipParameters.getFileNameInZip())) {
+ clonedZipParameters.setWriteExtendedLocalFileHeader(false);
+ clonedZipParameters.setCompressionMethod(CompressionMethod.STORE);
+ clonedZipParameters.setEncryptFiles(false);
+ clonedZipParameters.setEntrySize(0);
+ }
+
+ if (zipParameters.getLastModifiedFileTime() <= 0) {
+ clonedZipParameters.setLastModifiedFileTime(System.currentTimeMillis());
+ }
+
+ return clonedZipParameters;
+ }
}
=====================================
src/main/java/net/lingala/zip4j/model/ZipParameters.java
=====================================
@@ -299,7 +299,8 @@ public void setEncryptFiles(boolean encryptFiles) {
* @param lastModifiedFileTime the last modified time in milliseconds since the epoch
*/
public void setLastModifiedFileTime(long lastModifiedFileTime) {
- if (lastModifiedFileTime <= 0) {
+ if (lastModifiedFileTime < 0) {
+ this.lastModifiedFileTime = 0;
return;
}
=====================================
src/main/java/net/lingala/zip4j/tasks/AbstractExtractFileTask.java
=====================================
@@ -77,8 +77,12 @@ public abstract class AbstractExtractFileTask<T> extends AsyncZipTask<T> {
outputFileCanonicalPath = outputFileCanonicalPath + FILE_SEPARATOR;
}
+ String outputCanonicalPath = (new File(outputPath).getCanonicalPath());
+ if (!outputCanonicalPath.endsWith(FILE_SEPARATOR)) {
+ outputCanonicalPath += FILE_SEPARATOR;
+ }
+
// make sure no file is extracted outside the target directory (a.k.a. zip slip)
- String outputCanonicalPath = (new File(outputPath).getCanonicalPath()) + File.separator;
if (!outputFileCanonicalPath.startsWith(outputCanonicalPath)) {
throw new ZipException("illegal file name that breaks out of the target directory: "
+ fileHeader.getFileName());
=====================================
src/main/java/net/lingala/zip4j/tasks/AbstractModifyFileTask.java
=====================================
@@ -15,7 +15,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
-import java.util.Random;
+import java.security.SecureRandom;
abstract class AbstractModifyFileTask<T> extends AsyncZipTask<T> {
@@ -24,7 +24,7 @@ abstract class AbstractModifyFileTask<T> extends AsyncZipTask<T> {
}
File getTemporaryFile(String zipPathWithName) {
- Random random = new Random();
+ SecureRandom random = new SecureRandom();
File tmpFile = new File(zipPathWithName + random.nextInt(10000));
while (tmpFile.exists()) {
=====================================
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 (!fileCanonicalPath.startsWith(rootFolderFileRef)) {
+ if (!fileToAdd.getCanonicalFile().toPath().startsWith(rootFolderFileRef)) {
tmpFileName = fileToAdd.getCanonicalFile().getParentFile().getName() + FILE_SEPARATOR + fileToAdd.getCanonicalFile().getName();
} else {
tmpFileName = fileCanonicalPath.substring(rootFolderFileRef.length());
@@ -469,11 +469,11 @@ public class FileUtils {
DosFileAttributeView fileAttributeView = Files.getFileAttributeView(file, DosFileAttributeView.class, LinkOption.NOFOLLOW_LINKS);
- //IntelliJ complains that fileAttributes can never be null. But apparently it can.
+ //IntelliJ complains that fileAttributeView can never be null. But apparently it can.
//See https://github.com/srikanth-lingala/zip4j/issues/435
//Even the javadoc of Files.getFileAttributeView says it can be null
//noinspection ConstantConditions
- if (fileAttributes == null) {
+ if (fileAttributeView == null) {
return;
}
=====================================
src/test/java/net/lingala/zip4j/ZipFileZip64IT.java
=====================================
@@ -8,7 +8,7 @@ import net.lingala.zip4j.model.enums.CompressionMethod;
import net.lingala.zip4j.model.enums.RandomAccessFileMode;
import net.lingala.zip4j.testutils.HeaderVerifier;
import net.lingala.zip4j.testutils.RandomInputStream;
-import net.lingala.zip4j.testutils.SlowTests;
+import net.lingala.zip4j.testutils.SlowTest;
import net.lingala.zip4j.testutils.TestUtils;
import net.lingala.zip4j.testutils.ZipFileVerifier;
import net.lingala.zip4j.util.InternalZipConstants;
@@ -28,7 +28,7 @@ import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
- at Category(SlowTests.class)
+ at Category(SlowTest.class)
public class ZipFileZip64IT extends AbstractIT {
private byte[] readBuffer = new byte[2 * InternalZipConstants.BUFF_SIZE];
=====================================
src/test/java/net/lingala/zip4j/io/inputstream/ZipInputStreamIT.java
=====================================
@@ -27,7 +27,7 @@ import java.nio.file.Files;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
-import java.util.Random;
+import java.security.SecureRandom;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@@ -152,7 +152,7 @@ public class ZipInputStreamIT extends AbstractIT {
@Test
public void testExtractWithRandomLengthWithAesAndDeflateCompression() throws IOException {
- Random random = new Random();
+ SecureRandom random = new SecureRandom();
File createZipFile = createZipFile(CompressionMethod.DEFLATE, true, EncryptionMethod.AES, AesKeyStrength.KEY_STRENGTH_256, PASSWORD);
LocalFileHeader localFileHeader;
int readLen;
=====================================
src/test/java/net/lingala/zip4j/io/outputstream/ZipOutputStreamIT.java
=====================================
@@ -3,7 +3,9 @@ package net.lingala.zip4j.io.outputstream;
import net.lingala.zip4j.AbstractIT;
import net.lingala.zip4j.ZipFile;
import net.lingala.zip4j.exception.ZipException;
+import net.lingala.zip4j.io.inputstream.ZipInputStream;
import net.lingala.zip4j.model.FileHeader;
+import net.lingala.zip4j.model.LocalFileHeader;
import net.lingala.zip4j.model.Zip4jConfig;
import net.lingala.zip4j.model.ZipParameters;
import net.lingala.zip4j.model.enums.AesKeyStrength;
@@ -18,6 +20,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -288,6 +291,25 @@ public class ZipOutputStreamIT extends AbstractIT {
}
}
+ @Test
+ public void testLastModifiedTimeIsSetWhenItIsNotExplicitlySet() throws IOException {
+ long currentTime = System.currentTimeMillis();
+ ByteArrayOutputStream zip = new ByteArrayOutputStream();
+
+ try (ZipOutputStream zos = new ZipOutputStream(zip)) {
+ ZipParameters params = new ZipParameters();
+ params.setFileNameInZip("test");
+ zos.putNextEntry(params);
+ zos.closeEntry();
+ }
+
+ try (ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(zip.toByteArray()))) {
+ LocalFileHeader fileHeader = zis.getNextEntry();
+ long zipTime = fileHeader.getLastModifiedTimeEpoch();
+ assertThat(currentTime).isLessThan(zipTime + 2000);
+ }
+ }
+
private void testZipOutputStream(CompressionMethod compressionMethod, boolean encrypt,
EncryptionMethod encryptionMethod, AesKeyStrength aesKeyStrength,
AesVersion aesVersion)
=====================================
src/test/java/net/lingala/zip4j/testutils/RandomInputStream.java
=====================================
@@ -2,11 +2,11 @@ package net.lingala.zip4j.testutils;
import java.io.IOException;
import java.io.InputStream;
-import java.util.Random;
+import java.security.SecureRandom;
public class RandomInputStream extends InputStream {
- private static final Random RANDOM = new Random();
+ private static final SecureRandom RANDOM = new SecureRandom();
private long remaining;
private boolean streamClosed;
=====================================
src/test/java/net/lingala/zip4j/testutils/SlowTests.java → src/test/java/net/lingala/zip4j/testutils/SlowTest.java
=====================================
@@ -1,4 +1,4 @@
package net.lingala.zip4j.testutils;
-public interface SlowTests {
+public interface SlowTest {
}
View it on GitLab: https://salsa.debian.org/java-team/zip4j/-/compare/cca98517fed7ad01be5a58144803175ff7d9fdb9...08390db3b193e7be520c71b2016886f8f43b4010
--
View it on GitLab: https://salsa.debian.org/java-team/zip4j/-/compare/cca98517fed7ad01be5a58144803175ff7d9fdb9...08390db3b193e7be520c71b2016886f8f43b4010
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/20220916/0b0ff1cb/attachment.htm>
More information about the pkg-java-commits
mailing list