Adjust checking for Zip-Bomb errors so it also works on JDK >= 8
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1790508 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
77614b8c49
commit
48526517cd
@ -897,18 +897,15 @@ public final class TestPackage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkForZipBombException(Throwable e) {
|
private void checkForZipBombException(Throwable e) {
|
||||||
|
// unwrap InvocationTargetException as they usually contain the nested exception in the "target" member
|
||||||
if(e instanceof InvocationTargetException) {
|
if(e instanceof InvocationTargetException) {
|
||||||
InvocationTargetException t = (InvocationTargetException)e;
|
e = ((InvocationTargetException)e).getTargetException();
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String msg = e.getMessage();
|
String msg = e.getMessage();
|
||||||
if(msg != null && (msg.startsWith("Zip bomb detected!") ||
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user