diff options
author | PJ Fanning <fanningpj@apache.org> | 2021-12-10 18:07:25 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2021-12-10 18:07:25 +0000 |
commit | 11b0cf965cdae8f512daa5bb3c2dbd809e05d305 (patch) | |
tree | b3086cc7b65bc1cbfb9a17873d06c6a220f4ad12 /poi-ooxml | |
parent | 5ff9c60cbf34ee4c20daff9188318ef4a0f1216a (diff) | |
download | poi-11b0cf965cdae8f512daa5bb3c2dbd809e05d305.tar.gz poi-11b0cf965cdae8f512daa5bb3c2dbd809e05d305.zip |
[bug-65738] do not treat zip directories as parts
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1895788 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml')
-rw-r--r-- | poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java index 45c1f282e6..8feaf81252 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java +++ b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java @@ -308,6 +308,7 @@ public final class ZipPackage extends OPCPackage { // its relationship exists, and then it won't tie up) final List<EntryTriple> entries = Collections.list(zipArchive.getEntries()).stream() + .filter(zipArchiveEntry -> !ignoreEntry(zipArchiveEntry)) .map(zae -> new EntryTriple(zae, contentTypeManager)) .filter(mm -> mm.partName != null) .sorted() @@ -320,6 +321,11 @@ public final class ZipPackage extends OPCPackage { return newPartList; } + private static boolean ignoreEntry(ZipArchiveEntry zipArchiveEntry) { + String name = zipArchiveEntry.getName(); + return name.startsWith("[trash]") || name.endsWith("/"); + } + private class EntryTriple implements Comparable<EntryTriple> { final ZipArchiveEntry zipArchiveEntry; final PackagePartName partName; @@ -331,7 +337,7 @@ public final class ZipPackage extends OPCPackage { final String entryName = zipArchiveEntry.getName(); PackagePartName ppn = null; // ignore trash parts - if (!entryName.startsWith("[trash]")) { + if (!ignoreEntry(zipArchiveEntry)) { try { // We get an error when we parse [Content_Types].xml // because it's not a valid URI. |