]> source.dussan.org Git - poi.git/commitdiff
#59058 - OOM when parsing docx after OPCPackage.open with File but not with InputStre...
authorAndreas Beeker <kiwiwings@apache.org>
Wed, 9 Mar 2016 01:25:02 +0000 (01:25 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Wed, 9 Mar 2016 01:25:02 +0000 (01:25 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1734184 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/testcases/org/apache/poi/xwpf/TestXWPFBugs.java
test-data/document/bug57031.docx [new file with mode: 0644]
test-data/document/bug59058.docx [new file with mode: 0644]

index 6f7e4b689ec6c9f03ed0d886ba96522580629bcf..79bf0806d54375c0beff99fa4eb5bf82e0d020be 100644 (file)
@@ -21,11 +21,15 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;\r
 \r
 import java.io.File;\r
+import java.io.IOException;\r
 import java.io.InputStream;\r
+import java.util.zip.ZipEntry;\r
+import java.util.zip.ZipFile;\r
 \r
 import javax.crypto.Cipher;\r
 \r
 import org.apache.poi.POIDataSamples;\r
+import org.apache.poi.openxml4j.OpenXML4JTestDataSamples;\r
 import org.apache.poi.openxml4j.opc.OPCPackage;\r
 import org.apache.poi.poifs.crypt.CipherAlgorithm;\r
 import org.apache.poi.poifs.crypt.Decryptor;\r
@@ -34,8 +38,10 @@ import org.apache.poi.poifs.crypt.HashAlgorithm;
 import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;\r
 import org.apache.poi.xwpf.extractor.XWPFWordExtractor;\r
 import org.apache.poi.xwpf.usermodel.XWPFDocument;\r
+import org.apache.xmlbeans.XmlException;\r
 import org.junit.Assume;\r
 import org.junit.Test;\r
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.DocumentDocument;\r
 \r
 public class TestXWPFBugs {\r
     /**\r
@@ -106,4 +112,17 @@ public class TestXWPFBugs {
 \r
         filesystem.close();\r
     }\r
-}\r
+\r
+    \r
+    @Test\r
+    public void bug59058() throws IOException, XmlException {\r
+        String files[] = { "bug57031.docx", "bug59058.docx" };\r
+        for (String f : files) {\r
+            ZipFile zf = new ZipFile(POIDataSamples.getDocumentInstance().getFile(f));\r
+            ZipEntry entry = zf.getEntry("word/document.xml");\r
+            DocumentDocument document = DocumentDocument.Factory.parse(zf.getInputStream(entry));\r
+            assertNotNull(document);\r
+            zf.close();\r
+        }\r
+    }\r
+}
\ No newline at end of file
diff --git a/test-data/document/bug57031.docx b/test-data/document/bug57031.docx
new file mode 100644 (file)
index 0000000..6a1230e
Binary files /dev/null and b/test-data/document/bug57031.docx differ
diff --git a/test-data/document/bug59058.docx b/test-data/document/bug59058.docx
new file mode 100644 (file)
index 0000000..08808da
Binary files /dev/null and b/test-data/document/bug59058.docx differ