From 14754f33f40e3399236c0ca2282271f2bb929282 Mon Sep 17 00:00:00 2001 From: mOo Date: Tue, 20 Sep 2005 05:54:19 +0000 Subject: [PATCH] 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 --- src/connections.c | 1 - tests/core-condition.t | 23 +++++++++++------------ tests/lighttpd.conf | 22 ++++++++++++++-------- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/connections.c b/src/connections.c index dc2fc967..1b77caad 100644 --- a/src/connections.c +++ b/src/connections.c @@ -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) \ diff --git a/tests/core-condition.t b/tests/core-condition.t index 3e7e8ad9..4ca1f379 100755 --- a/tests/core-condition.t +++ b/tests/core-condition.t @@ -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} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ]; - ok($tf->handle_http($t) == 0, 'condition: Referer - referer doesn\'t match'); -} - $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ]; ok($tf->handle_http($t) == 0, 'condition: Referer - referer doesn\'t match'); +$t->{REQUEST} = ( <{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"); diff --git a/tests/lighttpd.conf b/tests/lighttpd.conf index a435e8f0..c6e86cd6 100644 --- a/tests/lighttpd.conf +++ b/tests/lighttpd.conf @@ -155,18 +155,28 @@ $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" ) } } +$HTTP["host"] =~ "bug255\.example\.org$" { + $HTTP["remoteip"] == "127.0.0.1" { + url.access-deny = ( "" ) + } +} + +$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)" { @@ -174,7 +184,3 @@ $HTTP["host"] == "referer.example.org" { } } -$HTTP["referer"] !~ "^($|http://referer\.example\.org)" { - url.access-deny = ( ".jpg" ) -} -