summaryrefslogtreecommitdiff
path: root/tests/core-condition.t
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2016-02-21 17:56:24 +0000
committerStefan B├╝hler <stbuehler@web.de>2016-02-21 17:56:24 +0000
commit1c01a42aa3bf1ff997ae1e58e53b88053f84faa8 (patch)
tree864377468a935e510a9bd5f5d577a107b5dfe666 /tests/core-condition.t
parent431559e5df7dfa6edfcea0371c09339e04b402c8 (diff)
downloadlighttpd1.4-1c01a42aa3bf1ff997ae1e58e53b88053f84faa8.tar.gz
lighttpd1.4-1c01a42aa3bf1ff997ae1e58e53b88053f84faa8.zip
[core] never evaluate else branches until the previous branches are aready (fixes #2598)
The first condition which evaluates true in any if-else... condition chain short-circuits the chain, and any remaining conditions in the chain are marked false. Previous conditions in if-else condition chaining must be evaluatable (to true or false) -- must not remain in unset (not yet evaluatable) state -- prior to evaluating later conditions. Since any true condition short-circuits remaining conditions, all prev conditions must be false prior to evaluating later conditions. From: Glenn Strauss <gstrauss@gluelogic.com> git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@3081 152afb58-edef-0310-8abb-c4023f1b3aa9
Diffstat (limited to 'tests/core-condition.t')
-rwxr-xr-xtests/core-condition.t17
1 files changed, 15 insertions, 2 deletions
diff --git a/tests/core-condition.t b/tests/core-condition.t
index 39b24e37..53b69c5e 100755
--- a/tests/core-condition.t
+++ b/tests/core-condition.t
@@ -8,7 +8,7 @@ BEGIN {
use strict;
use IO::Socket;
-use Test::More tests => 19;
+use Test::More tests => 21;
use LightyTest;
my $tf = LightyTest->new();
@@ -65,6 +65,20 @@ EOF
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => "/match_6" } ];
ok($tf->handle_http($t) == 0, 'url subdir with path traversal');
+$t->{REQUEST} = ( <<EOF
+GET / HTTP/1.0
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Server' => 'Apache 1.3.29' } ];
+ok($tf->handle_http($t) == 0, 'condition: handle if before else branches');
+
+$t->{REQUEST} = ( <<EOF
+GET /show/other/server-tag HTTP/1.0
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Server' => 'special tag' } ];
+ok($tf->handle_http($t) == 0, 'condition: handle if before else branches #2');
+
ok($tf->stop_proc == 0, "Stopping lighttpd");
$tf->{CONFIGFILE} = 'lighttpd.conf';
@@ -152,4 +166,3 @@ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ];
ok($tf->handle_http($t) == 0, 'condition: $HTTP["referer"] == "" and Referer: foobar');
ok($tf->stop_proc == 0, "Stopping lighttpd");
-