Mercurial > hg > nginx-tests
annotate rewrite_unescape.t @ 1553:01867708af95
Tests: adjusted todo_alerts() in js_subrequest.t.
author | Dmitry Volyntsev <xeioex@nginx.com> |
---|---|
date | Mon, 02 Mar 2020 19:46:52 +0300 |
parents | 882267679006 |
children |
rev | line source |
---|---|
149
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 # Tests for escaping/unescaping in rewrite module. |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 ############################################################################### |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 use warnings; |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 use strict; |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
12 use Test::More; |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 BEGIN { use FindBin; chdir($FindBin::Bin); } |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 use lib 'lib'; |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 use Test::Nginx; |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 ############################################################################### |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 select STDERR; $| = 1; |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 select STDOUT; $| = 1; |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
24 my $t = Test::Nginx->new()->has(qw/http rewrite/)->plan(9) |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
25 ->write_file_expand('nginx.conf', <<'EOF'); |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
26 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
27 %%TEST_GLOBALS%% |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
28 |
249
6a0d934950bc
Tests: remove extra spaces in "daemon off".
Maxim Dounin <mdounin@mdounin.ru>
parents:
212
diff
changeset
|
29 daemon off; |
149
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
30 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
31 events { |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
32 } |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
34 http { |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
35 %%TEST_GLOBALS_HTTP%% |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
36 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
37 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
38 listen 127.0.0.1:8080; |
149
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 server_name localhost; |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
41 location /t1 { |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
42 rewrite ^ $arg_r? redirect; |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
43 } |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
44 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
45 location /t2 { |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 rewrite ^ http://example.com$request_uri? redirect; |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 } |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
49 location /t3 { |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 rewrite ^ http://example.com$uri redirect; |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 } |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
52 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 location /t4 { |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 rewrite ^(.*) http://example.com$1 redirect; |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 } |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
56 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 location /t5 { |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 rewrite ^ http://example.com/blah%20%3Fblah redirect; |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
59 } |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
60 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
61 location /t6 { |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
62 rewrite ^ http://example.com/blah%20%2Fblah redirect; |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
63 } |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
64 } |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 } |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
66 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
67 EOF |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
68 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
69 mkdir($t->testdir() . '/directory'); |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
70 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
71 $t->run(); |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
72 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
73 ############################################################################### |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
74 |
596
e36b267021e3
Tests: partially reverted 6cdfd177319b.
Maxim Dounin <mdounin@mdounin.ru>
parents:
595
diff
changeset
|
75 # Some rewrites and expected (?) behaviour |
212 | 76 # |
149
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
77 # /t1?r=http%3A%2F%2Fexample.com%2F%3Ffrom |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
78 # rewrite ^ $arg_r? redirect; |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
79 # expected: http://example.com/?from |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
80 # got: http://example.com/?from |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
81 # |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
82 # /t1?r=http%3A%2F%2Fexample.com%0D%0Asplit |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
83 # rewrite ^ $arg_r? redirect; |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
84 # expected: http://example.com%0D%0Asplit |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
85 # got: http://example.com%0D%0Asplit |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
86 # |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
87 # /t1?r=http%3A%2F%2Fexample.com%2F%3Ffrom%3Dblah |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
88 # rewrite ^ $arg_r? redirect; |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
89 # expected: http://example.com/?from=blah |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
90 # got: http://example.com/?from%3Dblah |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
91 # |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
92 # /blah%3Fblah |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
93 # rewrite ^ http://example.com$request_uri? redirect; |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
94 # expected: http://example.com/blah%3Fblah |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
95 # got: http://example.com/blah?blah |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
96 # |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
97 # /blah%3Fblah |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
98 # rewrite ^ http://example.com$uri redirect; |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
99 # expected: http://example.com/blah%3Fblah |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
100 # got: http://example.com/blah?blah |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
101 # |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
102 # /blah%3Fblah |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
103 # rewrite ^(.*) http://example.com$1 redirect; |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
104 # expected: http://example.com/blah%3Fblah |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
105 # got: http://example.com/blah?blah |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
106 # |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
107 # / |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
108 # rewrite ^ http://example.com/blah%3Fblah redirect; |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
109 # expected: http://example.com/blah%3Fblah |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
110 # got: http://example.com/blah?blah |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
111 # |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
112 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
113 location('/t1?r=http%3A%2F%2Fexample.com%2F%3Ffrom', |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
114 'http://example.com/?from', 'escaped argument'); |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
115 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
116 location('/t1?r=http%3A%2F%2Fexample.com%0D%0Asplit', |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
117 'http://example.com%0D%0Asplit', 'escaped argument header splitting'); |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
118 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
119 TODO: { |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
120 local $TODO = 'not yet'; |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
121 |
595
6cdfd177319b
Tests: fixed typos and misspellings.
Sergey Kandaurov <pluknet@nginx.com>
parents:
249
diff
changeset
|
122 # Fixing this cases will require major changes to the whole approach and |
149
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
123 # likely to break some currently working cases. On the other hand, current |
596
e36b267021e3
Tests: partially reverted 6cdfd177319b.
Maxim Dounin <mdounin@mdounin.ru>
parents:
595
diff
changeset
|
124 # behaviour is far from acceptable. Should be carefully thought. |
149
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
125 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
126 location('/t1?r=http%3A%2F%2Fexample.com%2F%3Ffrom%3Dblah', |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
127 'http://example.com/?from=blah', 'escaped argument with complex query'); |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
128 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
129 location('/t2/blah%20%3Fblah', |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
130 'http://example.com/t2/blah%20%3Fblah', 'escaped $request_uri'); |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
131 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
132 location('/t3/blah%20%3Fblah', |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
133 'http://example.com/t3/blah%20%3Fblah', 'escaped $uri'); |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
134 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
135 location('/t4/blah%20%3Fblah', |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
136 'http://example.com/t4/blah%20%3Fblah', 'escaped $1'); |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
137 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
138 location('/t5', |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
139 'http://example.com/blah%20%3Fblah', 'escaped static'); |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
140 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
141 location('/t5?arg=blah', |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
142 'http://example.com/blah%20%3Fblah?arg=blah', |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
143 'escaped static with argument'); |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
144 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
145 location('/t6', |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
146 'http://example.com/blah%20%2Fblah', 'escaped static slash'); |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
147 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
148 } |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
149 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
150 ############################################################################### |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
151 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
152 sub location { |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
153 my ($url, $value, $name) = @_; |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
154 my $data = http_get($url); |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
155 if ($data !~ qr!^Location: (.*?)\x0d?$!ms) { |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
156 fail($name); |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
157 return; |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
158 } |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
159 my $location = $1; |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
160 is($location, $value, $name); |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
161 } |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
162 |
2178954eee5d
Tests: add tests for rewrite escaping problems.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
163 ############################################################################### |