From: Greg Beaver Date: Sat, 5 Jan 2008 03:49:01 +0000 (+0000) Subject: fix Location header for index if request has a /, 2 new tests, add index.php to front... X-Git-Tag: RELEASE_2_0_0a1~1027 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=08b7b76418b6094b7f6116f35e925a1f4793d3e4;p=php fix Location header for index if request has a /, 2 new tests, add index.php to frontcontroller phar --- diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 487f01c3b5..bb248514b3 100755 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -432,7 +432,7 @@ PHP_METHOD(Phar, webPhar) zend_bailout(); return; } else { - char *tmp, sa; + char *tmp, sa, *myentry; sapi_header_line ctr = {0}; ctr.response_code = 301; ctr.line_len = sizeof("HTTP/1.1 301 Moved Permanently")+1; @@ -443,7 +443,12 @@ PHP_METHOD(Phar, webPhar) sa = *tmp; *tmp = '\0'; ctr.response_code = 0; - ctr.line_len = spprintf(&(ctr.line), 4096, "Location: %s%s", path_info, entry); + if (entry[0] == '/' && path_info[strlen(path_info)-1] == '/') { + myentry = entry + 1; + } else { + myentry = entry; + } + ctr.line_len = spprintf(&(ctr.line), 4096, "Location: %s%s", path_info, myentry); *tmp = sa; sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC); sapi_send_headers(TSRMLS_C); diff --git a/ext/phar/tests/frontcontroller.phar b/ext/phar/tests/frontcontroller.phar index 8790f7bc5b..626bf48acf 100644 Binary files a/ext/phar/tests/frontcontroller.phar and b/ext/phar/tests/frontcontroller.phar differ diff --git a/ext/phar/tests/frontcontroller.phar.inc b/ext/phar/tests/frontcontroller.phar.inc index 989909751e..80d42e886b 100644 --- a/ext/phar/tests/frontcontroller.phar.inc +++ b/ext/phar/tests/frontcontroller.phar.inc @@ -4,6 +4,7 @@ $a = new Phar(dirname(__FILE__) . '/frontcontroller.phar'); $a['a.php'] = 'hio'; $a['a.jpg'] = 'hio'; $a['a.phps'] = 'setStub(' +--ENV-- +SCRIPT_NAME=/frontcontroller4.php +REQUEST_URI=/frontcontroller4.php +--FILE_EXTERNAL-- +frontcontroller.phar +--EXPECTHEADERS-- +Status: 301 Moved Permanently +Location: /frontcontroller4.php/index.php +--EXPECT-- diff --git a/ext/phar/tests/frontcontroller5.phpt b/ext/phar/tests/frontcontroller5.phpt new file mode 100644 index 0000000000..70d985712c --- /dev/null +++ b/ext/phar/tests/frontcontroller5.phpt @@ -0,0 +1,13 @@ +--TEST-- +Phar front controller phps +--SKIPIF-- + +--ENV-- +SCRIPT_NAME=/frontcontroller5.php/ +REQUEST_URI=/frontcontroller5.php/ +--FILE_EXTERNAL-- +frontcontroller.phar +--EXPECTHEADERS-- +Status: 301 Moved Permanently +Location: /frontcontroller5.php/index.php +--EXPECT--