Package aQute.lib.zip

Class ZipUtil


  • public class ZipUtil
    extends java.lang.Object
    This class provides utilities to work with zip files. http://www.opensource.apple.com/source/zip/zip-6/unzip/unzip/proginfo/extra. fld
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) static class  ZipUtil.State  
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.TimeZone tz  
    • Constructor Summary

      Constructors 
      Constructor Description
      ZipUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String cleanPath​(java.lang.String path)
      Clean the input path to avoid ZipSlip issues.
      static long getModifiedTime​(java.util.zip.ZipEntry entry)  
      static boolean isCompromised​(java.lang.String path)  
      static void setModifiedTime​(java.util.zip.ZipEntry entry, long utc)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • tz

        private static final java.util.TimeZone tz
    • Constructor Detail

      • ZipUtil

        public ZipUtil()
    • Method Detail

      • getModifiedTime

        public static long getModifiedTime​(java.util.zip.ZipEntry entry)
      • setModifiedTime

        public static void setModifiedTime​(java.util.zip.ZipEntry entry,
                                           long utc)
      • cleanPath

        public static java.lang.String cleanPath​(java.lang.String path)
        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 be null.
        Returns:
        Cleansed ZipEntry path.
        Throws:
        java.io.UncheckedIOException - If the entry used '..' relative paths to back up past the start of the path.
      • isCompromised

        public static boolean isCompromised​(java.lang.String path)