Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Prevent extracting folder if it matches $p_remove_path #2

Merged
merged 1 commit into from

2 participants

Josh Schmidt Michiel Rook
Josh Schmidt

Consider an archive with the following contents:

- folder_name
- folder_name/file_name.txt

Currently, $archive->ExtractModify( 'extract_folder', 'folder_name' ) will result in the following

- extract_folder/folder_name
- extract_folder/file_name.txt

instead of

- extract_folder/file_name.txt
Michiel Rook mrook merged commit 9419838 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 11, 2012
  1. Josh Schmidt
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 2 deletions.
  1. +6 −2 Archive/Tar.php
8 Archive/Tar.php
View
@@ -1599,10 +1599,14 @@ function _extractList($p_path, &$p_list_detail, $p_mode,
if (($v_extract_file) && (!$v_listing))
{
if (($p_remove_path != '')
- && (substr($v_header['filename'], 0, $p_remove_path_size)
- == $p_remove_path))
+ && (substr($v_header['filename'].'/', 0, $p_remove_path_size)
+ == $p_remove_path)) {
$v_header['filename'] = substr($v_header['filename'],
$p_remove_path_size);
+ if( $v_header['filename'] == '' ){
+ continue;
+ }
+ }
if (($p_path != './') && ($p_path != '/')) {
while (substr($p_path, -1) == '/')
$p_path = substr($p_path, 0, strlen($p_path)-1);
Something went wrong with that request. Please try again.