From 1dc190e680e903ddb6c7d5983050d2576f003cc0 Mon Sep 17 00:00:00 2001 From: Greg Beaver Date: Wed, 23 Apr 2008 17:18:28 +0000 Subject: [PATCH] improve rewrite callback support, add test for callback that does not return string/false --- ext/phar/phar_object.c | 14 +++++++------ ext/phar/tests/files/frontcontroller18.phar | Bin 0 -> 331 bytes .../tests/files/frontcontroller18.phar.inc | 19 ++++++++++++++++++ ext/phar/tests/frontcontroller33.phpt | 13 ++++++++++++ 4 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 ext/phar/tests/files/frontcontroller18.phar create mode 100644 ext/phar/tests/files/frontcontroller18.phar.inc create mode 100644 ext/phar/tests/frontcontroller33.phpt 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 0000000000000000000000000000000000000000..b24d619a9d74fcce7ca9ff58dfe2d9beb4c6691c GIT binary patch literal 331 zcmcDqFUTn1N-NDvF3HT#Qz+I@Nz~-3=Bni?DXLVc<_gG2EV8mHPfY?bG?YqGi%awh zfJ`MF1ttB=yp+@mAh!U>%PY;v(NRb&DoU)>&;&{rD`{GD)hZ+>mLz8=Xt-7+rxt)M zP)XGU8k>@ts-cpqYnPr{;+tAroS2@fp{by!pcIn_*2a~ZoRP1fl%HQvtdNqKqL7zg zqEJ+t2b8tuDoZSiPbtkU&`^nY^$XKcP>BzA4GMD&0$LXz@8ReZ67THq8{p~V8l<6V ztzd7*%Vo~Mz`zK^f>0Vr0Rblv!#x0!%F5*T0MTAySGu=>)B}MHICLPc$;brS&a(bh d(1UsL=65>|&wjAu&SsvR`_fE6h3-ziP5^prURwYF literal 0 HcmV?d00001 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 -- 2.50.1