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 f537f139f2..4362f62d14 100644 --- a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java +++ b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java @@ -897,18 +897,15 @@ public final class TestPackage { } private void checkForZipBombException(Throwable e) { + // unwrap InvocationTargetException as they usually contain the nested exception in the "target" member if(e instanceof InvocationTargetException) { - InvocationTargetException t = (InvocationTargetException)e; - IOException t2 = (IOException)t.getTargetException(); - if(t2.getMessage().startsWith("Zip bomb detected!") || - t2.getMessage().startsWith("The parser has encountered more than \"4,096\" entity expansions in this document;")) { - return; - } + e = ((InvocationTargetException)e).getTargetException(); } String msg = e.getMessage(); if(msg != null && (msg.startsWith("Zip bomb detected!") || - msg.startsWith("The parser has encountered more than \"4,096\" entity expansions in this document;"))) { + msg.contains("The parser has encountered more than \"4,096\" entity expansions in this document;") || + msg.contains("The parser has encountered more than \"4096\" entity expansions in this document;"))) { return; }