use strict; use warnings FATAL => 'all'; use Apache::Test; use Apache::TestRequest; use Apache::TestUtil; use MIME::Base64; use Data::Dumper; use HTTP::Response; use Socket; # undef: HTTPD should drop connection without error message my @test_cases = ( # request, status code global, status code 'mergeslashes off' VH, msg [ "GET /authz_core/a/b/c/index.html HTTP/1.1\r\nHost: merge-default\r\nConnection: close\r\n\r\n" => 403, "exact match"], [ "GET //authz_core/a/b/c/index.html HTTP/1.1\r\nHost: merge-default\r\nConnection: close\r\n\r\n" => 403, "merged even at front"], [ "GET ///authz_core/a/b/c/index.html HTTP/1.1\r\nHost: merge-default\r\nConnection: close\r\n\r\n" => 403, "merged even at front"], [ "GET /authz_core/a/b/c//index.html HTTP/1.1\r\nHost: merge-default\r\nConnection: close\r\n\r\n" => 403, "c// should be merged"], [ "GET /authz_core/a//b/c/index.html HTTP/1.1\r\nHost: merge-default\r\nConnection: close\r\n\r\n" => 403, "a// should be merged"], [ "GET /authz_core/a//b/c/index.html HTTP/1.1\r\nHost: merge-disabled\r\nConnection: close\r\n\r\n" => 403, "a// matches locationmatch"], [ "GET /authz_core/a/b/c//index.html HTTP/1.1\r\nHost: merge-disabled\r\nConnection: close\r\n\r\n" => 200, "c// doesn't match locationmatch"], [ "GET /authz_core/a/b/d/index.html HTTP/1.1\r\nHost: merge-disabled\r\nConnection: close\r\n\r\n" => 403, "baseline failed", need_min_apache_version('2.4.47')], [ "GET /authz_core/a/b//d/index.html HTTP/1.1\r\nHost: merge-disabled\r\nConnection: close\r\n\r\n" => 403, "b//d not merged for Location with OFF",need_min_apache_version('2.4.47')], ); plan tests => scalar(@test_cases), need_min_apache_version('2.4.39'); foreach my $t (@test_cases) { my $req = $t->[0]; my $expect = $t->[1]; my $desc = $t->[2]; my $cond = $t->[3]; my $decoded; if (defined($cond) && !$cond) { skip("n/a"); } my $sock = Apache::TestRequest::vhost_socket("core"); if (!$sock) { print "# failed to connect\n"; ok(0); next; } $sock->print($req); sleep(0.1); $req = escape($req); print "# SENDING to " . peer($sock) . "\n# $req\n"; my $response_data = ""; my $buf; while ($sock->read($buf, 10000) > 0) { $response_data .= $buf; } my $response = HTTP::Response->parse($response_data); if ($decoded) { $response_data =~ s/