From: Greg Beaver Date: Wed, 23 Apr 2008 17:18:28 +0000 (+0000) Subject: improve rewrite callback support, add test for callback that does not return string... X-Git-Tag: RELEASE_2_0_0b1~253 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1dc190e680e903ddb6c7d5983050d2576f003cc0;p=php improve rewrite callback support, add test for callback that does not return string/false --- diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 35b8cbd53e..a8fcc6b0f2 100755 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -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) { diff --git a/ext/phar/tests/files/frontcontroller18.phar b/ext/phar/tests/files/frontcontroller18.phar new file mode 100644 index 0000000000..b24d619a9d Binary files /dev/null and b/ext/phar/tests/files/frontcontroller18.phar differ diff --git a/ext/phar/tests/files/frontcontroller18.phar.inc b/ext/phar/tests/files/frontcontroller18.phar.inc new file mode 100644 index 0000000000..847a713ba3 --- /dev/null +++ b/ext/phar/tests/files/frontcontroller18.phar.inc @@ -0,0 +1,19 @@ +setStub('getMessage() . "\n"); +} +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/frontcontroller33.phpt b/ext/phar/tests/frontcontroller33.phpt new file mode 100644 index 0000000000..e1bc2a79fb --- /dev/null +++ b/ext/phar/tests/frontcontroller33.phpt @@ -0,0 +1,13 @@ +--TEST-- +Phar front controller with valid callback that does not return any value +--SKIPIF-- + +--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 \ No newline at end of file