From: Greg Beaver Date: Sat, 2 Feb 2008 05:20:37 +0000 (+0000) Subject: fix logic of path redirection. always prepend index_php with "/" if it doesn't have it, X-Git-Tag: RELEASE_2_0_0a1~660 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2b9a4279dd111d8152070b504515336ac9c243fc;p=php fix logic of path redirection. always prepend index_php with "/" if it doesn't have it, and then if path_info ends with "/" just use entry + 1 --- diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 8c68386752..ed31877f65 100755 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -433,6 +433,10 @@ PHP_METHOD(Phar, webPhar) if (index_php_len) { entry = index_php; entry_len = index_php_len; + if (entry[0] != '/') { + spprintf(&entry, 0, "/%s", index_php); + entry_len++; + } } else { /* assume "index.php" is starting point */ entry = estrndup("/index.php", sizeof("/index.php")); @@ -446,7 +450,7 @@ PHP_METHOD(Phar, webPhar) zend_bailout(); return; } else { - char *tmp, sa, *myentry; + char *tmp, sa; sapi_header_line ctr = {0}; ctr.response_code = 301; ctr.line_len = sizeof("HTTP/1.1 301 Moved Permanently")+1; @@ -457,12 +461,11 @@ PHP_METHOD(Phar, webPhar) sa = *tmp; *tmp = '\0'; ctr.response_code = 0; - if (entry[0] == '/' && path_info[strlen(path_info)-1] == '/') { - myentry = entry + 1; + if (path_info[strlen(path_info)-1] == '/') { + ctr.line_len = spprintf(&(ctr.line), 4096, "Location: %s%s", path_info, entry + 1); } else { - myentry = entry; + ctr.line_len = spprintf(&(ctr.line), 4096, "Location: %s%s", path_info, 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);