]> granicus.if.org Git - php/commitdiff
fix Location header for index if request has a /, 2 new tests, add index.php to front...
authorGreg Beaver <cellog@php.net>
Sat, 5 Jan 2008 03:49:01 +0000 (03:49 +0000)
committerGreg Beaver <cellog@php.net>
Sat, 5 Jan 2008 03:49:01 +0000 (03:49 +0000)
ext/phar/phar_object.c
ext/phar/tests/frontcontroller.phar
ext/phar/tests/frontcontroller.phar.inc
ext/phar/tests/frontcontroller4.phpt [new file with mode: 0644]
ext/phar/tests/frontcontroller5.phpt [new file with mode: 0644]

index 487f01c3b5b7ac6d4d0196aeb16d67610731e5b8..bb248514b3c808127f7cf651d868085fb2542305 100755 (executable)
@@ -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);
index 8790f7bc5b5db4bf823ab5ccc26128c3d51a313a..626bf48acf0596c465b08772ececb62bc52409e5 100644 (file)
Binary files a/ext/phar/tests/frontcontroller.phar and b/ext/phar/tests/frontcontroller.phar differ
index 989909751e556a3082d7e2e3708ddbe50838793f..80d42e886bf6cb9d4651546d0bfe3a1e6cf4d18c 100644 (file)
@@ -4,6 +4,7 @@ $a = new Phar(dirname(__FILE__) . '/frontcontroller.phar');
 $a['a.php'] = 'hio';
 $a['a.jpg'] = 'hio';
 $a['a.phps'] = '<?php function hio(){}';
+$a['index.php'] = 'here is my index';
 $a->setStub('<?php
 Phar::webPhar();
 echo "oops did not run\n";
diff --git a/ext/phar/tests/frontcontroller4.phpt b/ext/phar/tests/frontcontroller4.phpt
new file mode 100644 (file)
index 0000000..24e4fd9
--- /dev/null
@@ -0,0 +1,13 @@
+--TEST--
+Phar front controller phps
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--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 (file)
index 0000000..70d9857
--- /dev/null
@@ -0,0 +1,13 @@
+--TEST--
+Phar front controller phps
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller5.php/
+REQUEST_URI=/frontcontroller5.php/
+--FILE_EXTERNAL--
+frontcontroller.phar
+--EXPECTHEADERS--
+Status: 301 Moved Permanently
+Location: /frontcontroller5.php/index.php
+--EXPECT--