public class ZipSecureFile
extends org.apache.commons.compress.archivers.zip.ZipFile
ZipFile
in order to check the entries for
zip bombs while reading the archive.
The alert limits can be globally defined via setMaxEntrySize(long)
and setMinInflateRatio(double)
.
Constructor and Description |
---|
ZipSecureFile(java.io.File file) |
ZipSecureFile(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
ZipArchiveThresholdInputStream |
getInputStream(org.apache.commons.compress.archivers.zip.ZipArchiveEntry entry)
Returns an input stream for reading the contents of the specified zip file entry.
(返回用于读取指定 zip 文件条目内容的输入流。)
|
static long |
getMaxEntrySize()
Returns the current maximum allowed uncompressed file size.
(返回当前允许的最大未压缩文件大小。)
|
static long |
getMaxTextSize()
Returns the current maximum allowed text size.
(返回当前允许的最大文本大小。)
|
static double |
getMinInflateRatio()
Returns the current minimum compression rate that is used.
(返回当前使用的最小压缩率。)
|
java.lang.String |
getName()
Returns the path name of the ZIP file.
(返回 ZIP 文件的路径名。)
|
static void |
setMaxEntrySize(long maxEntrySize)
Sets the maximum file size of a single zip entry.
(设置单个 zip 条目的最大文件大小。)
|
static void |
setMaxTextSize(long maxTextSize)
Sets the maximum number of characters of text that are extracted before an exception is thrown during extracting text from documents.
(设置在从文档中提取文本期间引发异常之前提取的文本的最大字符数。)
|
static void |
setMinInflateRatio(double ratio)
Sets the ratio between de- and inflated bytes to detect zipbomb.
(设置 de- 和 inflated 字节之间的比率以检测 zipbomb。)
|
public ZipSecureFile(java.io.File file) throws java.io.IOException
java.io.IOException
(java.io.IOException)
public ZipSecureFile(java.lang.String name) throws java.io.IOException
java.io.IOException
(java.io.IOException)
public static void setMinInflateRatio(double ratio)
ratio
- the ratio between de- and inflated bytes to detect zipbomb
(ratio - 检测 zipbomb 的去膨胀字节和膨胀字节之间的比率)
public static double getMinInflateRatio()
public static void setMaxEntrySize(long maxEntrySize)
maxEntrySize
- the max. file size of a single zip entry
(maxEntrySize - 最大值。单个 zip 条目的文件大小)
public static long getMaxEntrySize()
public static void setMaxTextSize(long maxTextSize)
maxTextSize
- the max. file size of a single zip entry
(maxTextSize - 最大值。单个 zip 条目的文件大小)
public static long getMaxTextSize()
public ZipArchiveThresholdInputStream getInputStream(org.apache.commons.compress.archivers.zip.ZipArchiveEntry entry) throws java.io.IOException
Closing this ZIP file will, in turn, close all input streams that have been returned by invocations of this method.
(返回用于读取指定 zip 文件条目内容的输入流。关闭此 ZIP 文件将依次关闭调用此方法返回的所有输入流。)getInputStream
in class
org.apache.commons.compress.archivers.zip.ZipFile
entry
- the zip file entry
(entry - zip 文件条目)
java.io.IOException
- if an I/O error has occurred
(java.io.IOException - 如果发生 I/O 错误)
java.lang.IllegalStateException
- if the zip file has been closed
(java.lang.IllegalStateException - 如果 zip 文件已关闭)
public java.lang.String getName()
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.