From: Steph Fox Date: Thu, 28 Feb 2008 01:08:34 +0000 (+0000) Subject: Allow alias for phar.tar/phar.zip X-Git-Tag: RELEASE_2_0_0a1~304 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9e61358edaedcd423e07a2591f1389733e1dd112;p=php Allow alias for phar.tar/phar.zip --- diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 4bbac352aa..8c23751bbc 100755 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -1817,13 +1817,22 @@ PHP_METHOD(Phar, convertToZip) int ext_len = 0; PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &ext) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &ext, &ext_len) == FAILURE) { return; } - + +// need to check that the string isn't Phar::GZ etc + if (ext_len) { + if (strncmp(ext, "Phar::GZ", 8) || strncmp(ext, "Phar::BZ2", 9)) { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, + "Cannot compress a zip-based archive with gz or bz2"); + } + } + if (phar_obj->arc.archive->is_zip) { RETURN_TRUE; } + if (PHAR_G(readonly)) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Cannot write out phar archive, phar is read-only"); diff --git a/ext/phar/util.c b/ext/phar/util.c index b078c08c90..be27755832 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -139,7 +139,7 @@ void phar_rename_archive(phar_archive_data *phar, char *ext TSRMLS_DC) efree(basepath); efree(newname); - if (!strncmp(ext, "zip", 3) && !strncmp(ext, "tar", 3)) { + if (!phar->is_data) { phar->alias = estrndup(newpath, strlen(newpath)); phar->alias_len = strlen(newpath); zend_hash_update(&(PHAR_GLOBALS->phar_alias_map), newpath, strlen(newpath), (void*)&phar, sizeof(phar_archive_data*), NULL);