aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/poi/ss
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2020-08-14 20:26:21 +0000
committerAndreas Beeker <kiwiwings@apache.org>2020-08-14 20:26:21 +0000
commitb9841b4007c5a4590262600b51ee863bb7678168 (patch)
tree40abdfeb59ff86126d9e2c378cfcce249890d569 /src/java/org/apache/poi/ss
parent5caf8e109b8fac9341091b7a7bc94a29db01c267 (diff)
downloadpoi-b9841b4007c5a4590262600b51ee863bb7678168.tar.gz
poi-b9841b4007c5a4590262600b51ee863bb7678168.zip
also handle wrapped OOXML "Package" nodes inside of OLE2 containers
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1880861 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi/ss')
-rw-r--r--src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java b/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java
index d9504fe63a..e755b09f5e 100644
--- a/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java
+++ b/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java
@@ -16,6 +16,7 @@
==================================================================== */
package org.apache.poi.ss.usermodel;
+import static org.apache.poi.extractor.ExtractorFactory.OOXML_PACKAGE;
import static org.apache.poi.poifs.crypt.EncryptionInfo.ENCRYPTION_INFO_ENTRY;
import java.io.BufferedInputStream;
@@ -130,7 +131,7 @@ public final class WorkbookFactory {
*/
public static Workbook create(final DirectoryNode root, String password) throws IOException {
// Encrypted OOXML files go inside OLE2 containers, is this one?
- if (root.hasEntry(Decryptor.DEFAULT_POIFS_ENTRY)) {
+ if (root.hasEntry(Decryptor.DEFAULT_POIFS_ENTRY) || root.hasEntry(OOXML_PACKAGE)) {
return wp(FileMagic.OOXML, w -> w.create(root, password));
} else {
return wp(FileMagic.OLE2, w -> w.create(root, password));
@@ -276,7 +277,8 @@ public final class WorkbookFactory {
} else if (fm == FileMagic.OLE2) {
final boolean ooxmlEnc;
try (POIFSFileSystem fs = new POIFSFileSystem(file, true)) {
- ooxmlEnc = fs.getRoot().hasEntry(Decryptor.DEFAULT_POIFS_ENTRY);
+ DirectoryNode root = fs.getRoot();
+ ooxmlEnc = root.hasEntry(Decryptor.DEFAULT_POIFS_ENTRY) || root.hasEntry(OOXML_PACKAGE);
}
return wp(ooxmlEnc ? FileMagic.OOXML : fm, w -> w.create(file, password, readOnly));
}