@@ -5011,6 +5011,7 @@ PHP_METHOD(PharFileInfo, compress)
5011
5011
PHP_METHOD (PharFileInfo , decompress )
5012
5012
{
5013
5013
char * error ;
5014
+ char * compression_type ;
5014
5015
PHAR_ENTRY_OBJECT ();
5015
5016
5016
5017
if (zend_parse_parameters_none () == FAILURE ) {
@@ -5061,12 +5062,24 @@ PHP_METHOD(PharFileInfo, decompress)
5061
5062
/* re-populate after copy-on-write */
5062
5063
entry_obj -> entry = zend_hash_str_find_ptr (& phar -> manifest , entry_obj -> entry -> filename , entry_obj -> entry -> filename_len );
5063
5064
}
5064
- if (!entry_obj -> entry -> fp ) {
5065
- if (FAILURE == phar_open_archive_fp (entry_obj -> entry -> phar )) {
5066
- zend_throw_exception_ex (spl_ce_BadMethodCallException , 0 , "Cannot decompress entry \"%s\", phar error: Cannot open phar archive \"%s\" for reading" , entry_obj -> entry -> filename , entry_obj -> entry -> phar -> fname );
5065
+ switch (entry_obj -> entry -> flags & PHAR_ENT_COMPRESSION_MASK ) {
5066
+ case PHAR_ENT_COMPRESSED_GZ :
5067
+ compression_type = "gzip" ;
5068
+ break ;
5069
+ case PHAR_ENT_COMPRESSED_BZ2 :
5070
+ compression_type = "bz2" ;
5071
+ break ;
5072
+ default :
5073
+ zend_throw_exception_ex (spl_ce_BadMethodCallException , 0 ,
5074
+ "Cannot decompress file compressed with unknown compression type" );
5067
5075
return ;
5068
- }
5069
- entry_obj -> entry -> fp_type = PHAR_FP ;
5076
+ }
5077
+ /* decompress this file indirectly */
5078
+ if (SUCCESS != phar_open_entry_fp (entry_obj -> entry , & error , 1 )) {
5079
+ zend_throw_exception_ex (spl_ce_BadMethodCallException , 0 ,
5080
+ "Phar error: Cannot decompress %s-compressed file \"%s\" in phar \"%s\": %s" , compression_type , entry_obj -> entry -> filename , entry_obj -> entry -> phar -> fname , error );
5081
+ efree (error );
5082
+ return ;
5070
5083
}
5071
5084
5072
5085
entry_obj -> entry -> old_flags = entry_obj -> entry -> flags ;
0 commit comments