2020import java .io .File ;
2121import java .io .IOException ;
2222import java .io .InputStream ;
23+ import java .io .UnsupportedEncodingException ;
2324import java .net .URL ;
2425import java .util .Date ;
2526import java .util .Enumeration ;
27+ import javax .annotation .Nonnull ;
2628
29+ import org .apache .commons .compress .archivers .zip .UnicodePathExtraField ;
2730import org .apache .commons .compress .archivers .zip .ZipArchiveEntry ;
2831import org .apache .commons .compress .archivers .zip .ZipFile ;
2932import org .apache .commons .compress .utils .IOUtils ;
33+
3034import org .codehaus .plexus .archiver .AbstractUnArchiver ;
3135import org .codehaus .plexus .archiver .ArchiverException ;
3236import org .codehaus .plexus .components .io .resources .PlexusIoResource ;
3337
34- import javax .annotation .Nonnull ;
35-
3638/**
3739 * @author <a href="mailto:[email protected] ">Emmanuel Venisse</a> 3840 * @version $Id$
@@ -84,7 +86,20 @@ private static class ZipEntryFileInfo
8486
8587 public String getName ()
8688 {
87- return zipEntry .getName ();
89+ try
90+ {
91+ final UnicodePathExtraField unicodePath =
92+ (UnicodePathExtraField ) zipEntry .getExtraField ( UnicodePathExtraField .UPATH_ID );
93+
94+ return unicodePath != null
95+ ? new String ( unicodePath .getUnicodeName (), "UTF-8" )
96+ : zipEntry .getName ();
97+
98+ }
99+ catch ( final UnsupportedEncodingException e )
100+ {
101+ throw new AssertionError ( e );
102+ }
88103 }
89104
90105 public boolean isDirectory ()
@@ -141,27 +156,30 @@ protected void execute()
141156 InputStream in = null ;
142157 try
143158 {
144- zf = new org .apache .commons .compress .archivers .zip .ZipFile ( getSourceFile (), encoding );
145- final Enumeration e = zf .getEntries ();
159+ zf = new org .apache .commons .compress .archivers .zip .ZipFile ( getSourceFile (), encoding , true );
160+ final Enumeration e = zf .getEntriesInPhysicalOrder ();
146161 while ( e .hasMoreElements () )
147162 {
148163 final ZipArchiveEntry ze = (ZipArchiveEntry ) e .nextElement ();
149164 final ZipEntryFileInfo fileInfo = new ZipEntryFileInfo ( zf , ze );
150- if ( isSelected ( ze .getName (), fileInfo ) )
165+ if ( isSelected ( fileInfo .getName (), fileInfo ) )
151166 {
152- in = zf .getInputStream ( ze );
153- extractFileIfIncluded (getSourceFile (), getDestDirectory (), in , ze .getName (),
154- new Date (ze .getTime ()), ze .isDirectory (), ze .getUnixMode () != 0 ? ze .getUnixMode () : null ,
155- resolveSymlink ( zf , ze ) );
167+ in = zf .getInputStream ( ze );
168+
169+ extractFileIfIncluded ( getSourceFile (), getDestDirectory (), in , fileInfo .getName (),
170+ new Date ( ze .getTime () ), ze .isDirectory (),
171+ ze .getUnixMode () != 0 ? ze .getUnixMode () : null ,
172+ resolveSymlink ( zf , ze ) );
173+
156174 in .close ();
157175 in = null ;
158- }
159-
160- }
176+ }
177+ }
161178
162- getLogger ().debug ( "expand complete" );
163179 zf .close ();
164180 zf = null ;
181+
182+ getLogger ().debug ( "expand complete" );
165183 }
166184 catch ( final IOException ioe )
167185 {
@@ -197,9 +215,9 @@ protected void execute( final String path, final File outputDirectory )
197215 InputStream in = null ;
198216 try
199217 {
200- zipFile = new org .apache .commons .compress .archivers .zip .ZipFile ( getSourceFile (), encoding );
218+ zipFile = new org .apache .commons .compress .archivers .zip .ZipFile ( getSourceFile (), encoding , true );
201219
202- final Enumeration e = zipFile .getEntries ();
220+ final Enumeration e = zipFile .getEntriesInPhysicalOrder ();
203221
204222 while ( e .hasMoreElements () )
205223 {
@@ -213,9 +231,12 @@ protected void execute( final String path, final File outputDirectory )
213231 if ( ze .getName ().startsWith ( path ) )
214232 {
215233 in = zipFile .getInputStream ( ze );
234+
216235 extractFileIfIncluded ( getSourceFile (), outputDirectory , in ,
217236 ze .getName (), new Date ( ze .getTime () ), ze .isDirectory (),
218- ze .getUnixMode () != 0 ? ze .getUnixMode () : null , resolveSymlink ( zipFile , ze ) );
237+ ze .getUnixMode () != 0 ? ze .getUnixMode () : null ,
238+ resolveSymlink ( zipFile , ze ) );
239+
219240 in .close ();
220241 in = null ;
221242 }
0 commit comments