This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit df0015ada427fd88c13e7effbc47062ca6cc1cb0 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sun Jan 28 17:23:21 2024 -0500 Sort members --- .../archivers/zip/ZipArchiveInputStreamTest.java | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java index 5d64283c6..f24b811ac 100644 --- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java @@ -713,26 +713,12 @@ public class ZipArchiveInputStreamTest extends AbstractTest { } } - @ParameterizedTest - @ValueSource(booleans = { true, false }) - public void zipInputStream(final boolean allowStoredEntriesWithDataDescriptor) { - try (ZipArchiveInputStream zIn = new ZipArchiveInputStream(Files.newInputStream(Paths.get("src/test/resources/COMPRESS-647/test.zip")), - CharsetNames.UTF_8, false, allowStoredEntriesWithDataDescriptor)) { - ZipArchiveEntry zae = zIn.getNextEntry(); - while (zae != null) { - zae = zIn.getNextEntry(); - } - } catch (final IOException e) { - // Ignore expected exception - } - } - @Test - public void testZipWithShortBeginningGarbage() throws IOException { + public void testZipWithLongerBeginningGarbage() throws IOException { Path path = createTempPath("preamble", ".zip"); try (OutputStream fos = Files.newOutputStream(path)) { - fos.write("#!/usr/bin/unzip\n".getBytes(StandardCharsets.UTF_8)); + fos.write("#!/usr/bin/env some-program with quite a few arguments to make it longer than the local header\n".getBytes(StandardCharsets.UTF_8)); try (ZipArchiveOutputStream zos = new ZipArchiveOutputStream(fos)) { ZipArchiveEntry entry = new ZipArchiveEntry("file-1.txt"); entry.setMethod(ZipEntry.DEFLATED); @@ -751,11 +737,11 @@ public class ZipArchiveInputStreamTest extends AbstractTest { } @Test - public void testZipWithLongerBeginningGarbage() throws IOException { + public void testZipWithShortBeginningGarbage() throws IOException { Path path = createTempPath("preamble", ".zip"); try (OutputStream fos = Files.newOutputStream(path)) { - fos.write("#!/usr/bin/env some-program with quite a few arguments to make it longer than the local header\n".getBytes(StandardCharsets.UTF_8)); + fos.write("#!/usr/bin/unzip\n".getBytes(StandardCharsets.UTF_8)); try (ZipArchiveOutputStream zos = new ZipArchiveOutputStream(fos)) { ZipArchiveEntry entry = new ZipArchiveEntry("file-1.txt"); entry.setMethod(ZipEntry.DEFLATED); @@ -772,4 +758,18 @@ public class ZipArchiveInputStreamTest extends AbstractTest { assertArrayEquals("entry-content\n".getBytes(StandardCharsets.UTF_8), content); } } + + @ParameterizedTest + @ValueSource(booleans = { true, false }) + public void zipInputStream(final boolean allowStoredEntriesWithDataDescriptor) { + try (ZipArchiveInputStream zIn = new ZipArchiveInputStream(Files.newInputStream(Paths.get("src/test/resources/COMPRESS-647/test.zip")), + CharsetNames.UTF_8, false, allowStoredEntriesWithDataDescriptor)) { + ZipArchiveEntry zae = zIn.getNextEntry(); + while (zae != null) { + zae = zIn.getNextEntry(); + } + } catch (final IOException e) { + // Ignore expected exception + } + } }