aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java3
-rw-r--r--src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java15
-rw-r--r--test-data/openxml4j/62592.thmxbin0 -> 3671 bytes
3 files changed, 18 insertions, 0 deletions
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java
index 40fc2139f5..975e21d981 100644
--- a/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java
+++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java
@@ -250,6 +250,9 @@ public final class ZipPackage extends OPCPackage {
final ZipArchiveEntry contentTypeEntry =
zipArchive.getEntry(CONTENT_TYPES_PART_NAME);
if (contentTypeEntry != null) {
+ if (this.contentTypeManager != null) {
+ throw new InvalidFormatException("ContentTypeManager can only be created once. This must be a cyclic relation?");
+ }
try {
this.contentTypeManager = new ZipContentTypeManager(
zipArchive.getInputStream(contentTypeEntry), this);
diff --git a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java
index a92906b765..ad7fe80c84 100644
--- a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java
+++ b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java
@@ -1090,6 +1090,21 @@ public final class TestPackage {
openInvalidFile("SampleSS.txt", true);
}
+ @Test(expected = InvalidFormatException.class)
+ public void testBug62592() throws Exception {
+ InputStream is = OpenXML4JTestDataSamples.openSampleStream("62592.thmx");
+ OPCPackage p = OPCPackage.open(is);
+ }
+
+ @Test
+ public void testBug62592SequentialCallsToGetParts() throws Exception {
+ //make absolutely certain that sequential calls don't throw InvalidFormatExceptions
+ String originalFile = OpenXML4JTestDataSamples.getSampleFileName("TestPackageCommon.docx");
+ OPCPackage p2 = OPCPackage.open(originalFile, PackageAccess.READ);
+ p2.getParts();
+ p2.getParts();
+ }
+
@Test
public void testDoNotCloseStream() throws IOException {
OutputStream os = Mockito.mock(OutputStream.class);
diff --git a/test-data/openxml4j/62592.thmx b/test-data/openxml4j/62592.thmx
new file mode 100644
index 0000000000..74489e3475
--- /dev/null
+++ b/test-data/openxml4j/62592.thmx
Binary files differ