@@ -82,14 +82,19 @@ public function extract($zip_file, $target_dir = null, $preserve_filepath = true
8282 }
8383
8484 } else if (function_exists ('gzinflate ' )) {
85+
8586 if (!$ files = $ this ->_list_files ()) {
8687 $ this ->set_error ('ZIP folder was empty. ' );
87-
8888 return false ;
8989 }
9090
9191 $ file_locations = array ();
9292 foreach ($ files as $ file => $ trash ) {
93+
94+ if (strpos ($ file ,'.. ' ) !== false ) {
95+ continue ;
96+ }
97+
9398 $ dirname = pathinfo ($ file , PATHINFO_DIRNAME );
9499 $ extension = (pathinfo ($ file , PATHINFO_EXTENSION ));
95100
@@ -205,12 +210,17 @@ public function native_unzip($zip_file, $target_dir = null, $preserve_filepath =
205210 $ name = dirname ($ name );
206211 $ is_dir_there = $ target_dir . $ name ;
207212
213+ if (strpos ($ is_dir_there ,'.. ' ) !== false ) {
214+ continue ;
215+ }
216+
208217 if ($ name != '. ' ) {
209218 $ dirs_tree [] = $ is_dir_there ;
210219
211220 }
212221
213222 }
223+
214224 $ dirs_tree = array_unique ($ dirs_tree );
215225
216226 foreach ($ dirs_tree as $ item ) {
@@ -238,6 +248,11 @@ public function native_unzip($zip_file, $target_dir = null, $preserve_filepath =
238248 $ size = zip_entry_filesize ($ entry );
239249 $ name = zip_entry_name ($ entry );
240250 $ target_file_to_save = normalize_path ($ target_dir . $ name , false );
251+
252+ if (strpos ($ target_file_to_save ,'.. ' ) !== false ) {
253+ continue ;
254+ }
255+
241256 $ target_file_to_save_dir = dirname ($ target_file_to_save );
242257 if (!is_dir ($ target_file_to_save_dir )){
243258 mkdir_recursive ($ target_file_to_save_dir );
@@ -263,8 +278,9 @@ public function native_unzip($zip_file, $target_dir = null, $preserve_filepath =
263278 }
264279 zip_close ($ archive );
265280 }
266-
267- return $ file_locations ;
281+ if (!empty ($ file_locations )) {
282+ $ file_locations = array_unique ($ file_locations );
283+ }
268284 }
269285
270286 return $ file_locations ;
@@ -569,6 +585,14 @@ private function _load_files_by_signatures(&$fh, $stop_on_file = false)
569585 */
570586 private function _extract_file ($ compressed_file_name , $ target_file_name = false , $ underscore_case = false )
571587 {
588+ if (strpos ($ target_file_name ,'.. ' ) !== false ) {
589+ return false ;
590+ }
591+
592+ if (strpos ($ compressed_file_name ,'.. ' ) !== false ) {
593+ return false ;
594+ }
595+
572596 if (!sizeof ($ this ->compressed_list )) {
573597 $ this ->set_debug ('Trying to unzip before loading file list... Loading it! ' );
574598 $ this ->_list_files (false , $ compressed_file_name );
0 commit comments