]> granicus.if.org Git - php/commitdiff
Allow alias for phar.tar/phar.zip
authorSteph Fox <sfox@php.net>
Thu, 28 Feb 2008 01:08:34 +0000 (01:08 +0000)
committerSteph Fox <sfox@php.net>
Thu, 28 Feb 2008 01:08:34 +0000 (01:08 +0000)
ext/phar/phar_object.c
ext/phar/util.c

index 4bbac352aa2c76a32b40559b46b57ff04cd6c513..8c23751bbcf17f521e3f1fa02f1c27ccdfefa4f6 100755 (executable)
@@ -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");
index b078c08c90f89694e19d4cde3b9f8a4b360be12a..be2775583299dc48654d5b245fdb9f3daba3e501 100644 (file)
@@ -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);