improve rewrite callback support, add test for callback that does not return string/false

This commit is contained in:
Greg Beaver 2008-04-23 17:18:28 +00:00
parent 5105552d5a
commit 1dc190e680
4 changed files with 40 additions and 6 deletions

View File

@ -647,7 +647,7 @@ PHP_METHOD(Phar, webPhar)
}
return;
}
if (!retval_ptr) {
if (!fci.retval_ptr_ptr || !retval_ptr) {
if (free_pathinfo) {
efree(path_info);
}
@ -657,8 +657,13 @@ PHP_METHOD(Phar, webPhar)
switch (Z_TYPE_P(retval_ptr)) {
case IS_STRING :
efree(entry);
entry = Z_STRVAL_P(retval_ptr);
entry_len = Z_STRLEN_P(retval_ptr);
if (fci.retval_ptr_ptr != &retval_ptr) {
entry = estrndup(Z_STRVAL_PP(fci.retval_ptr_ptr), Z_STRLEN_PP(fci.retval_ptr_ptr));
entry_len = Z_STRLEN_PP(fci.retval_ptr_ptr);
} else {
entry = Z_STRVAL_P(retval_ptr);
entry_len = Z_STRLEN_P(retval_ptr);
}
break;
case IS_BOOL :
phar_do_403(entry, entry_len TSRMLS_CC);
@ -667,9 +672,6 @@ PHP_METHOD(Phar, webPhar)
}
zend_bailout();
return;
case IS_NULL :
/* just use what we have now */
break;
default:
efree(retval_ptr);
if (free_pathinfo) {

Binary file not shown.

View File

@ -0,0 +1,19 @@
<?php
@unlink(dirname(__FILE__) . '/frontcontroller18.phar');
$a = new Phar(dirname(__FILE__) . '/frontcontroller18.phar');
$a['index.php'] = '<?php
echo "hi";
';
$a->setStub('<?php
function s($a)
{
}
try {
Phar::webPhar("test.phar", "/index.php", null, array(), "s");
} catch (Exception $e) {
die($e->getMessage() . "\n");
}
echo "oops did not run\n";
var_dump($_ENV, $_SERVER);
__HALT_COMPILER();');
?>

View File

@ -0,0 +1,13 @@
--TEST--
Phar front controller with valid callback that does not return any value
--SKIPIF--
<?php if (!extension_loaded("phar")) die("skip"); ?>
--ENV--
SCRIPT_NAME=/frontcontroller33.php
REQUEST_URI=/frontcontroller33.php
--EXPECTHEADERS--
Content-type: text/html
--FILE_EXTERNAL--
files/frontcontroller18.phar
--EXPECTF--
phar error: rewrite callback must return a string or false