Repository: commons-compress Updated Branches: refs/heads/master 19a620c90 -> f7cf7ab61
COMPRESS-356 properly deal with PAX header entries ending in slash Suggested-by: Jeremy Gustie <jeremy at gustie dot com> Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/823cdee9 Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/823cdee9 Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/823cdee9 Branch: refs/heads/master Commit: 823cdee9b18508e9e51913d110a20a406f55582b Parents: 19a620c Author: Stefan Bodewig <[email protected]> Authored: Fri May 20 18:42:10 2016 +0200 Committer: Stefan Bodewig <[email protected]> Committed: Fri May 20 18:42:10 2016 +0200 ---------------------------------------------------------------------- src/changes/changes.xml | 5 +++++ .../compress/archivers/tar/TarArchiveEntry.java | 2 +- .../archivers/tar/TarArchiveInputStreamTest.java | 15 +++++++++++++++ src/test/resources/COMPRESS-356.tar | Bin 0 -> 8192 bytes 4 files changed, 21 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-compress/blob/823cdee9/src/changes/changes.xml ---------------------------------------------------------------------- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 276bb66..e5517b3 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -65,6 +65,11 @@ The <action> type attribute can be add,update,fix,remove. TarArchiveInputStream failed to parse PAX headers that included blank lines. </action> + <action issue="COMPRESS-356" type="fix" date="2016-05-20" + due-to="Jeremy Gustie"> + TarArchiveInputStream failed to parse PAX headers whose tar + entry name ended with a slash. + </action> </release> <release version="1.11" date="2016-04-06" description="Release 1.11"> http://git-wip-us.apache.org/repos/asf/commons-compress/blob/823cdee9/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java index 941bbbd..a5050bf 100644 --- a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java +++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java @@ -856,7 +856,7 @@ public class TarArchiveEntry implements TarConstants, ArchiveEntry { return true; } - if (getName().endsWith("/")) { + if (!isPaxHeader() && !isGlobalPaxHeader() && getName().endsWith("/")) { return true; } http://git-wip-us.apache.org/repos/asf/commons-compress/blob/823cdee9/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java index 015748b..161ee12 100644 --- a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java @@ -313,6 +313,21 @@ public class TarArchiveInputStreamTest { } } + /** + * @link "https://issues.apache.org/jira/browse/COMPRESS-356" + */ + @Test + public void survivesPaxHeaderWithNameEndingInSlash() throws Exception { + final TarArchiveInputStream is = getTestStream("/COMPRESS-356.tar"); + try { + final TarArchiveEntry entry = is.getNextTarEntry(); + assertEquals("package/package.json", entry.getName()); + assertNull(is.getNextTarEntry()); + } finally { + is.close(); + } + } + private TarArchiveInputStream getTestStream(final String name) { return new TarArchiveInputStream( TarArchiveInputStreamTest.class.getResourceAsStream(name)); http://git-wip-us.apache.org/repos/asf/commons-compress/blob/823cdee9/src/test/resources/COMPRESS-356.tar ---------------------------------------------------------------------- diff --git a/src/test/resources/COMPRESS-356.tar b/src/test/resources/COMPRESS-356.tar new file mode 100644 index 0000000..4dd6be9 Binary files /dev/null and b/src/test/resources/COMPRESS-356.tar differ
