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");
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);