fix discovery of files hidden in a URL - makes using any regular front controller possible

This commit is contained in:
Greg Beaver 2008-04-21 17:59:28 +00:00
parent 2f56c7f343
commit 25cdc7de2b
4 changed files with 29 additions and 7 deletions

View File

@ -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);

View 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';

View File

@ -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"