poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1790508 - /poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java
Date Fri, 07 Apr 2017 06:38:24 GMT
Author: centic
Date: Fri Apr  7 06:38:23 2017
New Revision: 1790508

URL: http://svn.apache.org/viewvc?rev=1790508&view=rev
Log:
Adjust checking for Zip-Bomb errors so it also works on JDK >= 8

Modified:
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java?rev=1790508&r1=1790507&r2=1790508&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java Fri Apr  7
06:38:23 2017
@@ -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;
         }
         



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message