Mercurial > hg > nginx-tests
comparison ssi.t @ 1712:0605f9a6f7b0
Tests: added ssi echo encoding tests.
Notably, this covers strict URI characters escaping in HTML (NGX_ESCAPE_HTML).
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 29 Jun 2021 11:57:39 +0300 |
parents | 196d33c2bb45 |
children | 2a0a6035a1af |
comparison
equal
deleted
inserted
replaced
1711:6c03c329ed95 | 1712:0605f9a6f7b0 |
---|---|
20 | 20 |
21 select STDERR; $| = 1; | 21 select STDERR; $| = 1; |
22 select STDOUT; $| = 1; | 22 select STDOUT; $| = 1; |
23 | 23 |
24 my $t = Test::Nginx->new()->has(qw/http ssi cache proxy rewrite/) | 24 my $t = Test::Nginx->new()->has(qw/http ssi cache proxy rewrite/) |
25 ->plan(27); | 25 ->plan(30); |
26 | 26 |
27 $t->write_file_expand('nginx.conf', <<'EOF'); | 27 $t->write_file_expand('nginx.conf', <<'EOF'); |
28 | 28 |
29 %%TEST_GLOBALS%% | 29 %%TEST_GLOBALS%% |
30 | 30 |
88 $t->write_file('test1.html', 'X<!--#echo var="arg_test" -->X'); | 88 $t->write_file('test1.html', 'X<!--#echo var="arg_test" -->X'); |
89 $t->write_file('test2.html', | 89 $t->write_file('test2.html', |
90 'X<!--#include virtual="/test1.html?test=test" -->X'); | 90 'X<!--#include virtual="/test1.html?test=test" -->X'); |
91 $t->write_file('test3.html', | 91 $t->write_file('test3.html', |
92 'X<!--#set var="blah" value="test" --><!--#echo var="blah" -->X'); | 92 'X<!--#set var="blah" value="test" --><!--#echo var="blah" -->X'); |
93 $t->write_file('test4-echo-none.html', | |
94 'X<!--#set var="blah" value="<test>" -->' | |
95 . '<!--#echo var="blah" encoding="none" -->X'); | |
96 $t->write_file('test5-echo-url.html', | |
97 'X<!--#set var="blah" value="<test>" -->' | |
98 . '<!--#echo var="blah" encoding="url" -->X'); | |
99 $t->write_file('test6-echo-entity.html', | |
100 'X<!--#set var="blah" value="<test>" -->' | |
101 . '<!--#echo var="blah" encoding="entity" -->X'); | |
93 $t->write_file('test-args-rewrite.html', | 102 $t->write_file('test-args-rewrite.html', |
94 'X<!--#include virtual="/check?found" -->X'); | 103 'X<!--#include virtual="/check?found" -->X'); |
95 $t->write_file('test-empty1.html', 'X<!--#include virtual="/empty.html" -->X'); | 104 $t->write_file('test-empty1.html', 'X<!--#include virtual="/empty.html" -->X'); |
96 $t->write_file('test-empty2.html', | 105 $t->write_file('test-empty2.html', |
97 'X<!--#include virtual="/local/empty.html" -->X'); | 106 'X<!--#include virtual="/local/empty.html" -->X'); |
134 | 143 |
135 like(http_get('/test2.html'), qr/^XXtestXX$/m, 'argument via include'); | 144 like(http_get('/test2.html'), qr/^XXtestXX$/m, 'argument via include'); |
136 | 145 |
137 like(http_get('/test3.html'), qr/^XtestX$/m, 'set'); | 146 like(http_get('/test3.html'), qr/^XtestX$/m, 'set'); |
138 | 147 |
148 like(http_get('/test4-echo-none.html'), qr/^X<test>X$/m, | |
149 'echo encoding none'); | |
150 | |
151 TODO: { | |
152 local $TODO = 'no strict URI escaping yet' unless $t->has_version('1.21.1'); | |
153 | |
154 like(http_get('/test5-echo-url.html'), qr/^X%3Ctest%3EX$/m, | |
155 'echo encoding url'); | |
156 | |
157 } | |
158 | |
159 like(http_get('/test6-echo-entity.html'), qr/^X<test>X$/m, | |
160 'echo encoding entity'); | |
161 | |
139 # args should be in subrequest even if original request has no args and that | 162 # args should be in subrequest even if original request has no args and that |
140 # was queried somehow (e.g. by server rewrites) | 163 # was queried somehow (e.g. by server rewrites) |
141 | 164 |
142 like(http_get('/test-args-rewrite.html'), qr/^XX$/m, 'args only subrequest'); | 165 like(http_get('/test-args-rewrite.html'), qr/^XX$/m, 'args only subrequest'); |
143 | 166 |