From 3817f138f8f84126b09f9ed01fe8f93760b6b33f Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Tue, 20 Feb 2024 16:31:04 +0000 Subject: [PATCH] try to fix issue with invalid files after commons-compress upgrade git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1915895 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/openxml4j/util/ZipArchiveThresholdInputStream.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipArchiveThresholdInputStream.java b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipArchiveThresholdInputStream.java index 75e896e78b..6c65589ddc 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipArchiveThresholdInputStream.java +++ b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipArchiveThresholdInputStream.java @@ -155,7 +155,9 @@ public class ZipArchiveThresholdInputStream extends FilterInputStream { } return entry; } catch (ZipException ze) { - if (ze.getMessage().startsWith("Unexpected record signature")) { + final String msg = ze.getMessage(); + if (msg.startsWith("Unexpected record signature") + || msg.startsWith("Cannot find zip signature within the file")) { throw new NotOfficeXmlFileException( "No valid entries or contents found, this is not a valid OOXML (Office Open XML) file", ze); }