]> granicus.if.org Git - php/commitdiff
fix logic of path redirection. always prepend index_php with "/" if it doesn't have it,
authorGreg Beaver <cellog@php.net>
Sat, 2 Feb 2008 05:20:37 +0000 (05:20 +0000)
committerGreg Beaver <cellog@php.net>
Sat, 2 Feb 2008 05:20:37 +0000 (05:20 +0000)
and then if path_info ends with "/" just use entry + 1

ext/phar/phar_object.c

index 8c6838675242bcb4539637e85fbf89a68a87ed66..ed31877f65d372a521bb69f05ffc404306789e26 100755 (executable)
@@ -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);