]> granicus.if.org Git - php/commitdiff
fix discovery of files hidden in a URL - makes using any regular front controller...
authorGreg Beaver <cellog@php.net>
Mon, 21 Apr 2008 17:59:28 +0000 (17:59 +0000)
committerGreg Beaver <cellog@php.net>
Mon, 21 Apr 2008 17:59:28 +0000 (17:59 +0000)
ext/phar/phar_object.c
ext/phar/tests/files/frontcontroller8.phar
ext/phar/tests/files/frontcontroller8.phar.inc
ext/phar/tests/frontcontroller25.phpt [new file with mode: 0644]

index a3af3695d4d7e217c19b6b4e24e4ad0589e52f42..e50092b19566957e45c207074c62dcd47c83a938 100755 (executable)
@@ -384,7 +384,7 @@ nofile:
 
 static void phar_postprocess_ru_web(char *fname, int fname_len, char **entry, int *entry_len, char **ru, int *ru_len TSRMLS_DC) /* {{{ */
 {
-       char *e = *entry + 1, *u = NULL, *saveu = NULL;
+       char *e = *entry + 1, *u = NULL, *u1 = NULL, *saveu = NULL;
        int e_len = *entry_len - 1, u_len = 0;
        phar_archive_data **pphar;
 
@@ -406,15 +406,22 @@ static void phar_postprocess_ru_web(char *fname, int fname_len, char **entry, in
                        return;
                }
                if (u) {
+                       u1 = strrchr(e, '/');
                        u[0] = '/';
                        saveu = u;
-               }
-               u = strrchr(e, '/');
-               if (!u) {
-                       if (saveu) {
-                               saveu[0] = '/';
+                       e_len += u_len + 1;
+                       u = u1;
+                       if (!u) {
+                               return;
+                       }
+               } else {
+                       u = strrchr(e, '/');
+                       if (!u) {
+                               if (saveu) {
+                                       saveu[0] = '/';
+                               }
+                               return;
                        }
-                       return;
                }
                u[0] = '\0';
                u_len = strlen(u + 1);
index a53bfe899634d7244ed7cd6b2e90371ece2e35e9..bd1070fc4fe253b025d21006e9553f4695202400 100644 (file)
Binary files a/ext/phar/tests/files/frontcontroller8.phar and b/ext/phar/tests/files/frontcontroller8.phar differ
index 84f12ce8d9a6ca6b6af602a3d81fdae79eca66cf..243da136c19014cb28d548fb629846683e90c969 100644 (file)
@@ -2,6 +2,7 @@
 @unlink(dirname(__FILE__) . '/frontcontroller8.phar');
 $a = new Phar(dirname(__FILE__) . '/frontcontroller8.phar');
 $a['a.phps'] = 'hio1';
+$a['a1.phps'] = '<?php var_dump($_SERVER["REQUEST_URI"]);';
 $a['a.jpg'] = 'hio2';
 $a['a.php'] = '<?php function hio(){}';
 $a['fronk.gronk'] = 'hio3';
diff --git a/ext/phar/tests/frontcontroller25.phpt b/ext/phar/tests/frontcontroller25.phpt
new file mode 100644 (file)
index 0000000..0ac7bac
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+Phar front controller with extra path_info
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--ENV--
+SCRIPT_NAME=/frontcontroller25.php
+REQUEST_URI=/frontcontroller25.php/a1.phps/extra/stuff
+PATH_INFO=/a1.phps/extra/stuff
+--FILE_EXTERNAL--
+files/frontcontroller8.phar
+--EXPECTHEADERS--
+Content-type: text/html
+--EXPECTF--
+string(42) "/frontcontroller25.php/a1.phps/extra/stuff"
\ No newline at end of file