Bug #54289 [Asn->Opn]: Phar::extractTo() does not accept specific directories to be extracted

From: Date: Tue, 24 Oct 2017 06:40:51 +0000
Subject: Bug #54289 [Asn->Opn]: Phar::extractTo() does not accept specific directories to be extracted
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212010@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=54289&edit=1

 ID:                 54289
 Updated by:         kalle@php.net
 Reported by:        hpdl at oscommerce dot com
 Summary:            Phar::extractTo() does not accept specific
                     directories to be extracted
-Status:             Assigned
+Status:             Open
 Type:               Bug
 Package:            PHAR related
 Operating System:   MacOS 10.6.6
 PHP Version:        5.3.5
-Assigned To:        mike
+Assigned To:        
 Block user comment: N
 Private report:     N



Previous Comments:
------------------------------------------------------------------------
[2015-01-02 14:49:29] kassner@php.net

Reproducible on PHP 5.6.4.

------------------------------------------------------------------------
[2011-08-27 06:28:17] cweiske@php.net

I can confirm that - extracting directories does not work:

PHP Fatal error:  Uncaught exception 'PharException' with message
'Phar Error: attempted to extract non-existent file "doc/" from phar
"/home/cweiske/Dev/semanticscuttle/cwdev/dist/SemanticScuttle-0.98.X.phar"'
in /home/cweiske/Dev/semanticscuttle/cwdev/phartest.php:3

Stack trace:
#0 /home/cweiske/Dev/semanticscuttle/cwdev/phartest.php(3):
Phar->extractTo('/tmp/test/', 'doc/', true)
#1 {main}
  thrown in /home/cweiske/Dev/semanticscuttle/cwdev/phartest.php on line 3

------------------------------------------------------------------------
[2011-08-11 20:33:50] hpdl at oscommerce dot com

Bug still exists in PHP 5.3.7RC5.

------------------------------------------------------------------------
[2011-03-17 10:44:06] hpdl at oscommerce dot com

Description:
------------
Phar::extractTo() does not allow specific directories to be extracted. The 
documentation states the second parameter can be a file or directory to only 
extract the file or directory from the phar archive.

Specific files can be extracted however an exception is thrown when a directory is 
passed.

Test script:
---------------
<?php
  $phar = new Phar('/tmp/test.phar');
  $phar->buildFromDirectory('/path/to/source');
  unset($phar);

  $phar = new Phar('/tmp/test.phar');
  $phar->extractTo('/tmp/test/', 'subdir1/subdir2/', true); // throws
exception
//  $phar->extractTo('/tmp/test/', 'subdir1/subdir2/file.txt', true); //
works as intended
?>


Expected result:
----------------
The specific directory should be extracted from the phar archive.

Actual result:
--------------
Fatal error: Uncaught exception 'PharException' with message 'Phar Error: 
attempted to extract non-existent file "subdir1/subdir2/" from phar 
"/tmp/test.phar"' in /phar-test.php on line 7


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=54289&edit=1


Thread (11 messages)

« previous php.bugs (#212010) next »