Browse Source

an unset header is now treat as empty_string "" to make the conditional logic correct.

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@757 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.6
Xuefer 16 years ago
parent
commit
9be1abfb85
  1. 2
      src/base.h
  2. 2
      src/server.c
  3. 15
      tests/core-condition.t
  4. 2
      tests/core-request.t
  5. 4
      tests/lighttpd.conf

2
src/base.h

@ -516,6 +516,8 @@ typedef struct {
buffer *tmp_chunk_len;
buffer *empty_string; /* is necessary for cond_match */
buffer *cond_check_buf;
/* caches */

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

15
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");

2
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

4
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 = ( "" )
}

Loading…
Cancel
Save