mirror of
https://github.com/php/php-src.git
synced 2024-12-14 12:26:19 +08:00
improve rewrite callback support, add test for callback that does not return string/false
This commit is contained in:
parent
5105552d5a
commit
1dc190e680
@ -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) {
|
||||
|
BIN
ext/phar/tests/files/frontcontroller18.phar
Normal file
BIN
ext/phar/tests/files/frontcontroller18.phar
Normal file
Binary file not shown.
19
ext/phar/tests/files/frontcontroller18.phar.inc
Normal file
19
ext/phar/tests/files/frontcontroller18.phar.inc
Normal 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();');
|
||||
?>
|
13
ext/phar/tests/frontcontroller33.phpt
Normal file
13
ext/phar/tests/frontcontroller33.phpt
Normal 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
|
Loading…
Reference in New Issue
Block a user