You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2025/09/10 15:56:51 UTC
(tika) 03/05: TIKA-4469 -- backwards compatibility for versions of commons-compress before 1.28.0
This is an automated email from the ASF dual-hosted git repository.
tallison pushed a commit to branch branch_3_2x
in repository https://gitbox.apache.org/repos/asf/tika.git
commit 42d4e9d06b48056667c45249d02ffa8e8ea5c180
Author: tallison <ta...@apache.org>
AuthorDate: Wed Sep 10 11:22:53 2025 -0400
TIKA-4469 -- backwards compatibility for versions of commons-compress before 1.28.0
---
.../tika/detect/zip/DefaultZipContainerDetector.java | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-zip-commons/src/main/java/org/apache/tika/detect/zip/DefaultZipContainerDetector.java b/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-zip-commons/src/main/java/org/apache/tika/detect/zip/DefaultZipContainerDetector.java
index 1ea61d23b..7697b54e0 100644
--- a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-zip-commons/src/main/java/org/apache/tika/detect/zip/DefaultZipContainerDetector.java
+++ b/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-zip-commons/src/main/java/org/apache/tika/detect/zip/DefaultZipContainerDetector.java
@@ -24,11 +24,13 @@ import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
+import org.apache.commons.compress.archivers.ArchiveException;
import org.apache.commons.compress.archivers.ArchiveStreamFactory;
import org.apache.commons.compress.archivers.zip.UnsupportedZipFeatureException;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
import org.apache.commons.compress.archivers.zip.ZipFile;
+import org.apache.commons.compress.compressors.CompressorException;
import org.apache.commons.compress.compressors.CompressorStreamFactory;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.input.CloseShieldInputStream;
@@ -119,9 +121,15 @@ public class DefaultZipContainerDetector implements Detector {
return TIFF;
}
try {
- String name = ArchiveStreamFactory.detect(
- UnsynchronizedByteArrayInputStream.builder().setByteArray(prefix).setLength(length).get());
+ String name = ArchiveStreamFactory.detect(UnsynchronizedByteArrayInputStream
+ .builder()
+ .setByteArray(prefix)
+ .setLength(length)
+ .get());
return PackageConstants.getMediaType(name);
+ } catch (ArchiveException e) {
+ //compress versions before 1.28.0 need this
+ return MediaType.OCTET_STREAM;
} catch (IOException e) {
return MediaType.OCTET_STREAM;
}
@@ -133,6 +141,9 @@ public class DefaultZipContainerDetector implements Detector {
CompressorStreamFactory.detect(
UnsynchronizedByteArrayInputStream.builder().setByteArray(prefix).setLength(length).get());
return CompressorConstants.getMediaType(type);
+ } catch (CompressorException e) {
+ //compress versions before 1.28.0 need this
+ return MediaType.OCTET_STREAM;
} catch (IOException e) {
return MediaType.OCTET_STREAM;
}