Fix workaround for incorrect path info/scriptname if fastcgi prefix is "/" (fixes #729)

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2421 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.23
Stefan Bühler 14 years ago
parent 61332595cb
commit ce39062dd2

@ -7,6 +7,7 @@ NEWS
* Added some extra warning options in cmake and fix the resulting warnings (unused/static functions)
* New lighttpd man page (moved it to section 8) (fixes #1875)
* Create rrd file for empty rrdfile in mod_rrdtool (#1788)
* Fix workaround for incorrect path info/scriptname if fastcgi prefix is "/" (fixes #729)
- 1.4.22 - 2009-03-07
* Fix wrong lua type for CACHE_MISS/CACHE_HIT in mod_cml (fixes #533)

@ -3639,7 +3639,11 @@ static handler_t fcgi_check_extension(server *srv, connection *con, void *p_d, i
*/
/* the rewrite is only done for /prefix/? matches */
if (extension->key->ptr[0] == '/' &&
if (host->fix_root_path_name && extension->key->ptr[0] == '/' && extension->key->ptr[1] == '\0') {
buffer_copy_string(con->request.pathinfo, con->uri.path->ptr);
con->uri.path->used = 1;
con->uri.path->ptr[con->uri.path->used - 1] = '\0';
} else if (extension->key->ptr[0] == '/' &&
con->uri.path->used > extension->key->used &&
NULL != (pathinfo = strchr(con->uri.path->ptr + extension->key->used - 1, '/'))) {
/* rewrite uri.path and pathinfo */
@ -3648,10 +3652,6 @@ static handler_t fcgi_check_extension(server *srv, connection *con, void *p_d, i
con->uri.path->used -= con->request.pathinfo->used - 1;
con->uri.path->ptr[con->uri.path->used - 1] = '\0';
} else if (host->fix_root_path_name && extension->key->ptr[0] == '/' && extension->key->ptr[1] == '\0') {
buffer_copy_string(con->request.pathinfo, con->uri.path->ptr);
con->uri.path->used = 1;
con->uri.path->ptr[con->uri.path->used - 1] = '\0';
}
}
}

@ -159,3 +159,15 @@ $HTTP["host"] == "zzz.example.org" {
server.name = "zzz.example.org"
}
$HTTP["host"] == "wsgi.example.org" {
fastcgi.server = (
"/" =>
( (
"host" => "127.0.0.1", "port" => 10000,
"fix-root-scriptname" => "enable",
"check-local" => "disable",
"bin-path" => env.SRCDIR + "/fcgi-responder",
"max-procs" => 1,
) ),
)
}

@ -40,7 +40,13 @@ int main () {
printf("Status: 500 Internal Foo\r\n\r\n");
}
printf("test123");
if (0 == strcmp(p, "path_info")) {
printf("%s", getenv("PATH_INFO"));
} else if (0 == strcmp(p, "script_name")) {
printf("%s", getenv("SCRIPT_NAME"));
} else {
printf("test123");
}
}
return 0;

@ -7,7 +7,7 @@ BEGIN {
}
use strict;
use Test::More tests => 50;
use Test::More tests => 52;
use LightyTest;
my $tf = LightyTest->new();
@ -166,7 +166,7 @@ EOF
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/foo/bar' } ];
ok($tf->handle_http($t) == 0, 'PATH_INFO, check-local off');
ok($tf->stop_proc == 0, "Stopping lighttpd");
@ -282,7 +282,7 @@ EOF
SKIP: {
skip "no fcgi-responder found", 9 unless -x $tf->{BASEDIR}."/tests/fcgi-responder" || -x $tf->{BASEDIR}."/tests/fcgi-responder.exe";
skip "no fcgi-responder found", 11 unless -x $tf->{BASEDIR}."/tests/fcgi-responder" || -x $tf->{BASEDIR}."/tests/fcgi-responder.exe";
$tf->{CONFIGFILE} = 'fastcgi-responder.conf';
ok($tf->start_proc == 0, "Starting lighttpd with $tf->{CONFIGFILE}") or die();
@ -318,6 +318,23 @@ EOF
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'test123' } ];
ok($tf->handle_http($t) == 0, 'line-ending \r\n + \r\n');
$t->{REQUEST} = ( <<EOF
GET /abc/def/ghi?path_info HTTP/1.0
Host: wsgi.example.org
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/abc/def/ghi' } ];
ok($tf->handle_http($t) == 0, 'PATH_INFO (wsgi)');
$t->{REQUEST} = ( <<EOF
GET /abc/def/ghi?script_name HTTP/1.0
Host: wsgi.example.org
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '' } ];
ok($tf->handle_http($t) == 0, 'SCRIPT_NAME (wsgi)');
$t->{REQUEST} = ( <<EOF
GET /index.fcgi?die-at-end HTTP/1.0
Host: www.example.org

Loading…
Cancel
Save