/* check for "rewrite" urls */
if (SUCCESS == zend_hash_find(Z_ARRVAL_P(rewrites), entry, entry_len+1, (void **) &fd_ptr)) {
if (IS_STRING != Z_TYPE_PP(fd_ptr)) {
+ phar_entry_delref(phar TSRMLS_CC);
+#ifdef PHP_WIN32
+ efree(fname);
+#endif
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "phar rewrite value for \"%s\" was not a string", entry);
return;
}
if (FAILURE == phar_get_entry_data(&phar, fname, fname_len, entry, entry_len, "r", &error TSRMLS_CC)) {
phar_do_404(fname, fname_len, f404, f404_len, entry, entry_len TSRMLS_CC);
+ phar_entry_delref(phar TSRMLS_CC);
#ifdef PHP_WIN32
efree(fname);
#endif
ulong intkey;
if (HASH_KEY_IS_LONG == zend_hash_get_current_key_ex(Z_ARRVAL_P(mimeoverride), &key, &keylen, &intkey, 0, NULL)) {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Key of MIME type overrides array must be a file extension, was \"%d\"", intkey);
+ phar_entry_delref(phar TSRMLS_CC);
#ifdef PHP_WIN32
efree(fname);
#endif
}
if (FAILURE == zend_hash_get_current_data(Z_ARRVAL_P(mimeoverride), (void **) &val)) {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Failed to retrieve Mime type for extension \"%s\"", key);
+ phar_entry_delref(phar TSRMLS_CC);
#ifdef PHP_WIN32
efree(fname);
#endif
PHAR_SET_USER_MIME(Z_LVAL_P(val))
} else {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed");
+ phar_entry_delref(phar TSRMLS_CC);
+#ifdef PHP_WIN32
+ efree(fname);
+#endif
RETURN_FALSE;
}
break;
break;
default :
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed");
+ phar_entry_delref(phar TSRMLS_CC);
+#ifdef PHP_WIN32
+ efree(fname);
+#endif
RETURN_FALSE;
}
}
--- /dev/null
+--TEST--
+Phar front controller rewrite array invalid
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller11.php/a.php
+REQUEST_URI=/frontcontroller11.php/a.php
+--FILE_EXTERNAL--
+frontcontroller5.phar
+--EXPECTHEADERS--
+Content-type: text/html
+--EXPECTF--
+Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Key of MIME type overrides array must be a file extension, was "0"' in %sfrontcontroller11.php:2
+Stack trace:
+#0 %sfrontcontroller11.php(2): Phar::webPhar('whatever', 'index.php', '', Array)
+#1 {main}
+ thrown in %sfrontcontroller11.php on line 2
\ No newline at end of file
--- /dev/null
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller5.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller5.phar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+Phar::webPhar("whatever", "index.php", null, array(0 => "oops"));
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>