fix and add testcase for #255

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@716 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.6
Xuefer 18 years ago
parent 4f1b2f8ca0
commit 14754f33f4

@ -691,7 +691,6 @@ int connection_reset(server *srv, connection *con) {
CLEAN(authed_user);
CLEAN(server_name);
CLEAN(error_handler);
CLEAN(dst_addr_buf);
#undef CLEAN
#define CLEAN(x) \

@ -71,18 +71,6 @@ EOF
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ];
ok($tf->handle_http($t) == 0, 'condition: Referer - referer matches regex');
TODO: {
local $TODO = "referer matching in conditionals";
$t->{REQUEST} = ( <<EOF
GET /nofile.png HTTP/1.0
Host: referer.example.org
Referer: http://evil-referer.example.org/
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ];
ok($tf->handle_http($t) == 0, 'condition: Referer - referer doesn\'t match');
}
$t->{REQUEST} = ( <<EOF
GET /image.jpg HTTP/1.0
Host: www.example.org
@ -109,6 +97,17 @@ EOF
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ];
ok($tf->handle_http($t) == 0, 'condition: Referer - referer doesn\'t match');
$t->{REQUEST} = ( <<EOF
GET /nofile HTTP/1.1
Host: bug255.example.org
GET /nofile HTTP/1.1
Host: bug255.example.org
Connection: close
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 403 }, { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 403 } ];
ok($tf->handle_http($t) == 0, 'remote ip cache (#255)');
ok($tf->stop_proc == 0, "Stopping lighttpd");

@ -155,22 +155,21 @@ $HTTP["host"] =~ "(zzz).example.org" {
url.redirect = ( "^/redirect/$" => "http://localhost:2048/%1" )
}
$HTTP["host"] =~ "(remoteip).example.org" {
$HTTP["remoteip"] =~ "(127.0.0.1)" {
$HTTP["host"] =~ "(remoteip)\.example\.org" {
$HTTP["remoteip"] =~ "(127\.0\.0\.1)" {
url.redirect = ( "^/redirect/$" => "http://localhost:2048/%1" )
}
}
$HTTP["remoteip"] =~ "(127.0.0.1)" {
$HTTP["host"] =~ "(remoteip2).example.org" {
$HTTP["remoteip"] =~ "(127\.0\.0\.1)" {
$HTTP["host"] =~ "(remoteip2)\.example\.org" {
url.redirect = ( "^/redirect/$" => "http://localhost:2048/%1" )
}
}
# deny access for all image stealers
$HTTP["host"] == "referer.example.org" {
$HTTP["referer"] !~ "^($|http://referer\.example\.org)" {
url.access-deny = ( ".png" )
$HTTP["host"] =~ "bug255\.example\.org$" {
$HTTP["remoteip"] == "127.0.0.1" {
url.access-deny = ( "" )
}
}
@ -178,3 +177,10 @@ $HTTP["referer"] !~ "^($|http://referer\.example\.org)" {
url.access-deny = ( ".jpg" )
}
# deny access for all image stealers
$HTTP["host"] == "referer.example.org" {
$HTTP["referer"] !~ "^($|http://referer\.example\.org)" {
url.access-deny = ( ".png" )
}
}

Loading…
Cancel
Save