From: Andreas Beeker Date: Wed, 9 Mar 2016 01:25:02 +0000 (+0000) Subject: #59058 - OOM when parsing docx after OPCPackage.open with File but not with InputStre... X-Git-Tag: REL_3_15_BETA2~474 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=08bfa54296af5e5e01e7effafaf6aa860d20b0d6;p=poi.git #59058 - OOM when parsing docx after OPCPackage.open with File but not with InputStream (TIKA-1866) git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1734184 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/TestXWPFBugs.java b/src/ooxml/testcases/org/apache/poi/xwpf/TestXWPFBugs.java index 6f7e4b689e..79bf0806d5 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/TestXWPFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/TestXWPFBugs.java @@ -21,11 +21,15 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.io.File; +import java.io.IOException; import java.io.InputStream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; import javax.crypto.Cipher; import org.apache.poi.POIDataSamples; +import org.apache.poi.openxml4j.OpenXML4JTestDataSamples; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.poifs.crypt.CipherAlgorithm; import org.apache.poi.poifs.crypt.Decryptor; @@ -34,8 +38,10 @@ import org.apache.poi.poifs.crypt.HashAlgorithm; import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; import org.apache.poi.xwpf.extractor.XWPFWordExtractor; import org.apache.poi.xwpf.usermodel.XWPFDocument; +import org.apache.xmlbeans.XmlException; import org.junit.Assume; import org.junit.Test; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.DocumentDocument; public class TestXWPFBugs { /** @@ -106,4 +112,17 @@ public class TestXWPFBugs { filesystem.close(); } -} + + + @Test + public void bug59058() throws IOException, XmlException { + String files[] = { "bug57031.docx", "bug59058.docx" }; + for (String f : files) { + ZipFile zf = new ZipFile(POIDataSamples.getDocumentInstance().getFile(f)); + ZipEntry entry = zf.getEntry("word/document.xml"); + DocumentDocument document = DocumentDocument.Factory.parse(zf.getInputStream(entry)); + assertNotNull(document); + zf.close(); + } + } +} \ No newline at end of file diff --git a/test-data/document/bug57031.docx b/test-data/document/bug57031.docx new file mode 100644 index 0000000000..6a1230e6f3 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 index 0000000000..08808daec8 Binary files /dev/null and b/test-data/document/bug59058.docx differ