diff ssi.t @ 367:0726521e42f3

Tests: added tests for escaped and unsafe URIs. This covers problems in DAV, SSI, X-Accel-Redirect fixed in 1.5.9.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 25 Dec 2013 12:03:40 +0400
parents 6a0d934950bc
children 4ac3588485f5
line wrap: on
line diff
--- a/ssi.t
+++ b/ssi.t
@@ -23,7 +23,7 @@ select STDOUT; $| = 1;
 
 plan(skip_all => 'win32') if $^O eq 'MSWin32';
 
-my $t = Test::Nginx->new()->has(qw/http ssi cache proxy rewrite/)->plan(18);
+my $t = Test::Nginx->new()->has(qw/http ssi cache proxy rewrite/)->plan(21);
 
 $t->write_file_expand('nginx.conf', <<'EOF');
 
@@ -83,6 +83,14 @@ EOF
 	'X<!--#include virtual="/cache/empty.html" -->X');
 $t->write_file('empty.html', '');
 
+$t->write_file('unescape.html?', 'SEE-THIS');
+$t->write_file('unescape1.html',
+	'X<!--#include virtual="/tes%741.html?test=test" -->X');
+$t->write_file('unescape2.html',
+	'X<!--#include virtual="/unescape.html%3f" -->X');
+$t->write_file('unescape3.html',
+	'X<!--#include virtual="/test1.html%3ftest=test" -->X');
+
 $t->run();
 
 ###############################################################################
@@ -120,6 +128,20 @@ like(http_get('/test-empty2.html'), qr/H
 like(http_get('/test-empty3.html'), qr/HTTP/, 'empty with proxy');
 like(http_get('/test-empty3.html'), qr/HTTP/, 'empty with proxy cached');
 
+# handling of escaped URIs
+
+like(http_get('/unescape1.html'), qr/^XXtestXX$/m, 'escaped in path');
+
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.5.9');
+
+like(http_get('/unescape2.html'), qr/^XSEE-THISX$/m,
+	'escaped question in path');
+like(http_get('/unescape3.html'), qr/404 Not Found/,
+	'escaped query separator');
+
+}
+
 like(`grep -F '[alert]' ${\($t->testdir())}/error.log`, qr/^$/s, 'no alerts');
 
 ###############################################################################