aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/poi/poifs
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/poifs
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/poifs')
-rw-r--r--src/java/org/apache/poi/poifs/filesystem/DocumentFactoryHelper.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/java/org/apache/poi/poifs/filesystem/DocumentFactoryHelper.java b/src/java/org/apache/poi/poifs/filesystem/DocumentFactoryHelper.java
index 9ac5e94018..088b549283 100644
--- a/src/java/org/apache/poi/poifs/filesystem/DocumentFactoryHelper.java
+++ b/src/java/org/apache/poi/poifs/filesystem/DocumentFactoryHelper.java
@@ -17,6 +17,8 @@
package org.apache.poi.poifs.filesystem;
+import static org.apache.poi.extractor.ExtractorFactory.OOXML_PACKAGE;
+
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -69,7 +71,12 @@ public final class DocumentFactoryHelper {
* @throws IOException If an error occurs while decrypting or if the password does not match
*/
public static InputStream getDecryptedStream(final DirectoryNode root, String password)
- throws IOException {
+ throws IOException {
+ // first check if the node contains an plain package
+ if (root.hasEntry(OOXML_PACKAGE)) {
+ return root.createDocumentInputStream(OOXML_PACKAGE);
+ }
+
EncryptionInfo info = new EncryptionInfo(root);
Decryptor d = Decryptor.getInstance(info);
@@ -97,11 +104,11 @@ public final class DocumentFactoryHelper {
/**
* Checks that the supplied InputStream (which MUST
* support mark and reset) has a OOXML (zip) header at the start of it.<p>
- *
+ *
* If unsure if your InputStream does support mark / reset,
* use {@link FileMagic#prepareToCheckMagic(InputStream)} to wrap it and make
* sure to always use that, and not the original!
- *
+ *
* @param inp An InputStream which supports either mark/reset
*
* @deprecated in 3.17-beta2, use {@link FileMagic#valueOf(InputStream)} == FileMagic.OOXML instead