diff options
-rw-r--r-- | src/base.h | 2 | ||||
-rw-r--r-- | src/server.c | 2 | ||||
-rwxr-xr-x | tests/core-condition.t | 15 | ||||
-rwxr-xr-x | tests/core-request.t | 2 | ||||
-rw-r--r-- | tests/lighttpd.conf | 4 |
5 files changed, 17 insertions, 8 deletions
@@ -516,6 +516,8 @@ typedef struct { buffer *tmp_chunk_len; + buffer *empty_string; /* is necessary for cond_match */ + buffer *cond_check_buf; /* caches */ diff --git a/src/server.c b/src/server.c index 91e54124..1bba79f0 100644 --- a/src/server.c +++ b/src/server.c @@ -125,6 +125,7 @@ static server *server_init(void) { CLEAN(errorlog_buf); CLEAN(response_range); CLEAN(tmp_buf); + srv->empty_string = buffer_init_string(""); CLEAN(cond_check_buf); CLEAN(srvconf.errorlog_file); @@ -190,6 +191,7 @@ static void server_free(server *srv) { CLEAN(errorlog_buf); CLEAN(response_range); CLEAN(tmp_buf); + CLEAN(empty_string); CLEAN(cond_check_buf); CLEAN(srvconf.errorlog_file); diff --git a/tests/core-condition.t b/tests/core-condition.t index 13b33df2..96b05d87 100755 --- a/tests/core-condition.t +++ b/tests/core-condition.t @@ -110,27 +110,30 @@ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 403 }, { ' ok($tf->handle_http($t) == 0, 'remote ip cache (#255)'); $t->{REQUEST} = ( <<EOF -GET /empty-ref.jpg HTTP/1.0 +GET /empty-ref.noref HTTP/1.0 +Cookie: empty-ref EOF ); $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ]; -ok($tf->handle_http($t) == 0, 'condition: $HTTP["referer"] == "" and Referer: is no set'); +ok($tf->handle_http($t) == 0, 'condition: $HTTP["referer"] == "" and Referer is no set'); $t->{REQUEST} = ( <<EOF -GET /empty-ref.jpg HTTP/1.0 +GET /empty-ref.noref HTTP/1.0 +Cookie: empty-ref Referer: EOF ); $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ]; -ok($tf->handle_http($t) == 0, 'condition: $HTTP["referer"] == "" and Referer: is no set'); +ok($tf->handle_http($t) == 0, 'condition: $HTTP["referer"] == "" and Referer is empty'); $t->{REQUEST} = ( <<EOF -GET /empty-ref.jpg HTTP/1.0 +GET /empty-ref.noref HTTP/1.0 +Cookie: empty-ref Referer: foobar EOF ); $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ]; -ok($tf->handle_http($t) == 0, 'condition: $HTTP["referer"] == "" and Referer: is no set'); +ok($tf->handle_http($t) == 0, 'condition: $HTTP["referer"] == "" and Referer: foobar'); ok($tf->stop_proc == 0, "Stopping lighttpd"); diff --git a/tests/core-request.t b/tests/core-request.t index 35937f38..f6a486aa 100755 --- a/tests/core-request.t +++ b/tests/core-request.t @@ -250,7 +250,7 @@ GET /image.JPG HTTP/1.0 EOF ); $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Content-Type' => 'image/jpeg' } ]; -ok($tf->handle_http($t) == 0, 'Content-Type - image/jpeg'); +ok($tf->handle_http($t) == 0, 'Content-Type - image/jpeg (upper case)'); $t->{REQUEST} = ( <<EOF GET /a HTTP/1.0 diff --git a/tests/lighttpd.conf b/tests/lighttpd.conf index 1af1c267..d9dfd5b4 100644 --- a/tests/lighttpd.conf +++ b/tests/lighttpd.conf @@ -1,3 +1,5 @@ +debug.log-request-handling = "enable" +debug.log-condition-handling = "enable" server.document-root = "@SRCDIR@/tmp/lighttpd/servers/www.example.org/pages/" server.pid-file = "@SRCDIR@/tmp/lighttpd/lighttpd.pid" @@ -184,7 +186,7 @@ $HTTP["host"] == "referer.example.org" { } } -$HTTP["url"] == "/empty-ref.jpg" { +$HTTP["cookie"] =~ "empty-ref" { $HTTP["referer"] == "" { url.access-deny = ( "" ) } |