@@ -5042,6 +5042,7 @@ PHP_METHOD(PharFileInfo, compress)
5042
5042
PHP_METHOD (PharFileInfo , decompress )
5043
5043
{
5044
5044
char * error ;
5045
+ char * compression_type ;
5045
5046
PHAR_ENTRY_OBJECT ();
5046
5047
5047
5048
if (zend_parse_parameters_none () == FAILURE ) {
@@ -5092,12 +5093,24 @@ PHP_METHOD(PharFileInfo, decompress)
5092
5093
/* re-populate after copy-on-write */
5093
5094
entry_obj -> entry = zend_hash_str_find_ptr (& phar -> manifest , entry_obj -> entry -> filename , entry_obj -> entry -> filename_len );
5094
5095
}
5095
- if (!entry_obj -> entry -> fp ) {
5096
- if (FAILURE == phar_open_archive_fp (entry_obj -> entry -> phar )) {
5097
- 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 );
5096
+ switch (entry_obj -> entry -> flags & PHAR_ENT_COMPRESSION_MASK ) {
5097
+ case PHAR_ENT_COMPRESSED_GZ :
5098
+ compression_type = "gzip" ;
5099
+ break ;
5100
+ case PHAR_ENT_COMPRESSED_BZ2 :
5101
+ compression_type = "bz2" ;
5102
+ break ;
5103
+ default :
5104
+ zend_throw_exception_ex (spl_ce_BadMethodCallException , 0 ,
5105
+ "Cannot decompress file compressed with unknown compression type" );
5098
5106
return ;
5099
- }
5100
- entry_obj -> entry -> fp_type = PHAR_FP ;
5107
+ }
5108
+ /* decompress this file indirectly */
5109
+ if (SUCCESS != phar_open_entry_fp (entry_obj -> entry , & error , 1 )) {
5110
+ zend_throw_exception_ex (spl_ce_BadMethodCallException , 0 ,
5111
+ "Phar error: Cannot decompress %s-compressed file \"%s\" in phar \"%s\": %s" , compression_type , entry_obj -> entry -> filename , entry_obj -> entry -> phar -> fname , error );
5112
+ efree (error );
5113
+ return ;
5101
5114
}
5102
5115
5103
5116
entry_obj -> entry -> old_flags = entry_obj -> entry -> flags ;
0 commit comments