Package aQute.lib.zip
Class ZipUtil
java.lang.Object
aQute.lib.zip.ZipUtil
This class provides utilities to work with zip files.
http://www.opensource.apple.com/source/zip/zip-6/unzip/unzip/proginfo/extra.
fld
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringClean the input path to avoid ZipSlip issues.static byte[]extraFieldFromString(byte[] extra, String value) Add a ZIP extra field from a String.static longgetModifiedTime(ZipEntry entry) static booleanisCompromised(String path) static voidsetModifiedTime(ZipEntry entry, long utc) static StringstringFromExtraField(byte[] extra) Extract a String from a ZIP extra field.
-
Field Details
-
EXTID_BND
public static final int EXTID_BND- See Also:
-
-
Constructor Details
-
ZipUtil
public ZipUtil()
-
-
Method Details
-
getModifiedTime
-
setModifiedTime
-
cleanPath
Clean the input path to avoid ZipSlip issues.All double '/', '.' and '..' path entries are resolved and removed. The returned path will have a '/' at the end when the input path has a '/' at the end. A leading '/' is stripped. An empty string is unmodified.
- Parameters:
path- ZipEntry path. Must not benull.- Returns:
- Cleansed ZipEntry path.
- Throws:
UncheckedIOException- If the entry used '..' relative paths to back up past the start of the path.
-
isCompromised
-
extraFieldFromString
Add a ZIP extra field from a String.The String is UTF-8 encoded and the extra field uses the Header ID
EXTID_BND. -
stringFromExtraField
Extract a String from a ZIP extra field.The Header ID
EXTID_BNDis searched for in the specified extra field. If found, the UTF-8 encoded value is converted to a String and returned.If the specified extra field is not valid, the extra field is considered to be a UTF-8 encoded value and is converted to a String and returned.
- Returns:
- The String value contained in the ZIP extra field or
nullis there is noEXTID_BNDHeader ID and the ZIP extra field data is not invalid. - See Also:
-