1--TEST--
2Test output_add_rewrite_var() with and without nested session URL-Rewriting
3--EXTENSIONS--
4session
5--INI--
6session.trans_sid_tags="a=href,area=href,frame=src,form="
7url_rewriter.tags="a=href,area=href,frame=src,form="
8--FILE--
9<?php
10$testTags = <<<TEST
11
12<a href=""></a>
13<a href="./foo.php"></a>
14
15<a href="//php.net/foo.php"></a>
16<a href="http://php.net/foo.php"></a>
17<a href="bad://php.net/foo.php"></a>
18<a href="//www.php.net/foo.php"></a>
19
20<a href="//session-trans-sid.com/foo.php"></a>
21<a href="http://session-trans-sid.com/foo.php"></a>
22<a href="bad://session-trans-sid.com/foo.php"></a>
23<a href="//www.session-trans-sid.com/foo.php"></a>
24
25<a href="//url-rewriter.com/foo.php"></a>
26<a href="http://url-rewriter.com/foo.php"></a>
27<a href="bad://url-rewriter.com/foo.php"></a>
28<a href="//www.url-rewriter.com/foo.php"></a>
29
30<form action="" method="get"> </form>
31<form action="./foo.php" method="get"></form>
32
33<form action="//php.net/foo.php" method="get"></form>
34<form action="http://php.net/foo.php" method="get"></form>
35<form action="bad://php.net/foo.php" method="get"></form>
36<form action="//www.php.net/foo.php" method="get"></form>
37
38<form action="//session-trans-sid.com/bar.php" method="get"></form>
39<form action="http://session-trans-sid.com/bar.php" method="get"></form>
40<form action="bad://session-trans-sid.com/bar.php" method="get"></form>
41<form action="//www.session-trans-sid.com/bar.php" method="get"></form>
42
43<form action="//url-rewriter.com/bar.php" method="get"></form>
44<form action="http://url-rewriter.com/bar.php" method="get"></form>
45<form action="bad://url-rewriter.com/bar.php" method="get"></form>
46<form action="//www.url-rewriter.com/bar.php" method="get"></form>
47
48TEST;
49
50ob_start();
51
52ini_set('session.trans_sid_hosts', 'session-trans-sid.com');
53ini_set('url_rewriter.hosts', 'url-rewriter.com');
54
55ini_set('session.use_only_cookies', 1);
56ini_set('session.use_cookies', 1);
57ini_set('session.use_strict_mode', 0);
58ini_set('session.use_trans_sid', 0);
59
60output_add_rewrite_var('<name>', '<value>');
61
62echo "URL-Rewriting with output_add_rewrite_var() without transparent session id support\n";
63echo $testTags;
64
65ob_flush();
66
67output_reset_rewrite_vars();
68
69ini_set('session.use_only_cookies', 0);
70ini_set('session.use_cookies', 0);
71ini_set('session.use_strict_mode', 0);
72ini_set('session.use_trans_sid', 1);
73
74session_id('testid');
75session_start();
76
77output_add_rewrite_var('<NAME>', '<VALUE>');
78
79echo "\nURL-Rewriting with transparent session id support without output_add_rewrite_var()\n";
80echo $testTags;
81
82ob_end_flush();
83
84
85output_add_rewrite_var('<name2>', '<value2>');
86
87echo "\nURL-Rewriting with output_add_rewrite_var() without transparent session id support\n";
88echo $testTags;
89
90--EXPECTF--
91Deprecated: ini_set(): Usage of session.trans_sid_hosts INI setting is deprecated in %s on line 44
92URL-Rewriting with output_add_rewrite_var() without transparent session id support
93
94<a href="?%3Cname%3E=%3Cvalue%3E"></a>
95<a href="./foo.php?%3Cname%3E=%3Cvalue%3E"></a>
96
97<a href="//php.net/foo.php"></a>
98<a href="http://php.net/foo.php"></a>
99<a href="bad://php.net/foo.php"></a>
100<a href="//www.php.net/foo.php"></a>
101
102<a href="//session-trans-sid.com/foo.php"></a>
103<a href="http://session-trans-sid.com/foo.php"></a>
104<a href="bad://session-trans-sid.com/foo.php"></a>
105<a href="//www.session-trans-sid.com/foo.php"></a>
106
107<a href="//url-rewriter.com/foo.php?%3Cname%3E=%3Cvalue%3E"></a>
108<a href="http://url-rewriter.com/foo.php?%3Cname%3E=%3Cvalue%3E"></a>
109<a href="bad://url-rewriter.com/foo.php"></a>
110<a href="//www.url-rewriter.com/foo.php"></a>
111
112<form action="" method="get"><input type="hidden" name="&lt;name&gt;" value="&lt;value&gt;" /> </form>
113<form action="./foo.php" method="get"><input type="hidden" name="&lt;name&gt;" value="&lt;value&gt;" /></form>
114
115<form action="//php.net/foo.php" method="get"></form>
116<form action="http://php.net/foo.php" method="get"></form>
117<form action="bad://php.net/foo.php" method="get"></form>
118<form action="//www.php.net/foo.php" method="get"></form>
119
120<form action="//session-trans-sid.com/bar.php" method="get"></form>
121<form action="http://session-trans-sid.com/bar.php" method="get"></form>
122<form action="bad://session-trans-sid.com/bar.php" method="get"></form>
123<form action="//www.session-trans-sid.com/bar.php" method="get"></form>
124
125<form action="//url-rewriter.com/bar.php" method="get"><input type="hidden" name="&lt;name&gt;" value="&lt;value&gt;" /></form>
126<form action="http://url-rewriter.com/bar.php" method="get"><input type="hidden" name="&lt;name&gt;" value="&lt;value&gt;" /></form>
127<form action="bad://url-rewriter.com/bar.php" method="get"></form>
128<form action="//www.url-rewriter.com/bar.php" method="get"></form>
129
130Deprecated: ini_set(): Disabling session.use_only_cookies INI setting is deprecated in %s on line 61
131
132Deprecated: ini_set(): Enabling session.use_trans_sid INI setting is deprecated in %s on line 64
133
134URL-Rewriting with transparent session id support without output_add_rewrite_var()
135
136<a href="?PHPSESSID=testid&%3CNAME%3E=%3CVALUE%3E&%3Cname2%3E=%3Cvalue2%3E"></a>
137<a href="./foo.php?PHPSESSID=testid&%3CNAME%3E=%3CVALUE%3E&%3Cname2%3E=%3Cvalue2%3E"></a>
138
139<a href="//php.net/foo.php"></a>
140<a href="http://php.net/foo.php"></a>
141<a href="bad://php.net/foo.php"></a>
142<a href="//www.php.net/foo.php"></a>
143
144<a href="//session-trans-sid.com/foo.php?PHPSESSID=testid"></a>
145<a href="http://session-trans-sid.com/foo.php?PHPSESSID=testid"></a>
146<a href="bad://session-trans-sid.com/foo.php"></a>
147<a href="//www.session-trans-sid.com/foo.php"></a>
148
149<a href="//url-rewriter.com/foo.php?%3CNAME%3E=%3CVALUE%3E&%3Cname2%3E=%3Cvalue2%3E"></a>
150<a href="http://url-rewriter.com/foo.php?%3CNAME%3E=%3CVALUE%3E&%3Cname2%3E=%3Cvalue2%3E"></a>
151<a href="bad://url-rewriter.com/foo.php"></a>
152<a href="//www.url-rewriter.com/foo.php"></a>
153
154<form action="" method="get"><input type="hidden" name="&lt;NAME&gt;" value="&lt;VALUE&gt;" /><input type="hidden" name="&lt;name2&gt;" value="&lt;value2&gt;" /><input type="hidden" name="PHPSESSID" value="testid" /> </form>
155<form action="./foo.php" method="get"><input type="hidden" name="&lt;NAME&gt;" value="&lt;VALUE&gt;" /><input type="hidden" name="&lt;name2&gt;" value="&lt;value2&gt;" /><input type="hidden" name="PHPSESSID" value="testid" /></form>
156
157<form action="//php.net/foo.php" method="get"></form>
158<form action="http://php.net/foo.php" method="get"></form>
159<form action="bad://php.net/foo.php" method="get"></form>
160<form action="//www.php.net/foo.php" method="get"></form>
161
162<form action="//session-trans-sid.com/bar.php" method="get"><input type="hidden" name="PHPSESSID" value="testid" /></form>
163<form action="http://session-trans-sid.com/bar.php" method="get"><input type="hidden" name="PHPSESSID" value="testid" /></form>
164<form action="bad://session-trans-sid.com/bar.php" method="get"></form>
165<form action="//www.session-trans-sid.com/bar.php" method="get"></form>
166
167<form action="//url-rewriter.com/bar.php" method="get"><input type="hidden" name="&lt;NAME&gt;" value="&lt;VALUE&gt;" /><input type="hidden" name="&lt;name2&gt;" value="&lt;value2&gt;" /></form>
168<form action="http://url-rewriter.com/bar.php" method="get"><input type="hidden" name="&lt;NAME&gt;" value="&lt;VALUE&gt;" /><input type="hidden" name="&lt;name2&gt;" value="&lt;value2&gt;" /></form>
169<form action="bad://url-rewriter.com/bar.php" method="get"></form>
170<form action="//www.url-rewriter.com/bar.php" method="get"></form>
171
172URL-Rewriting with output_add_rewrite_var() without transparent session id support
173
174<a href="?%3CNAME%3E=%3CVALUE%3E&%3Cname2%3E=%3Cvalue2%3E"></a>
175<a href="./foo.php?%3CNAME%3E=%3CVALUE%3E&%3Cname2%3E=%3Cvalue2%3E"></a>
176
177<a href="//php.net/foo.php"></a>
178<a href="http://php.net/foo.php"></a>
179<a href="bad://php.net/foo.php"></a>
180<a href="//www.php.net/foo.php"></a>
181
182<a href="//session-trans-sid.com/foo.php"></a>
183<a href="http://session-trans-sid.com/foo.php"></a>
184<a href="bad://session-trans-sid.com/foo.php"></a>
185<a href="//www.session-trans-sid.com/foo.php"></a>
186
187<a href="//url-rewriter.com/foo.php?%3CNAME%3E=%3CVALUE%3E&%3Cname2%3E=%3Cvalue2%3E"></a>
188<a href="http://url-rewriter.com/foo.php?%3CNAME%3E=%3CVALUE%3E&%3Cname2%3E=%3Cvalue2%3E"></a>
189<a href="bad://url-rewriter.com/foo.php"></a>
190<a href="//www.url-rewriter.com/foo.php"></a>
191
192<form action="" method="get"><input type="hidden" name="&lt;NAME&gt;" value="&lt;VALUE&gt;" /><input type="hidden" name="&lt;name2&gt;" value="&lt;value2&gt;" /> </form>
193<form action="./foo.php" method="get"><input type="hidden" name="&lt;NAME&gt;" value="&lt;VALUE&gt;" /><input type="hidden" name="&lt;name2&gt;" value="&lt;value2&gt;" /></form>
194
195<form action="//php.net/foo.php" method="get"></form>
196<form action="http://php.net/foo.php" method="get"></form>
197<form action="bad://php.net/foo.php" method="get"></form>
198<form action="//www.php.net/foo.php" method="get"></form>
199
200<form action="//session-trans-sid.com/bar.php" method="get"></form>
201<form action="http://session-trans-sid.com/bar.php" method="get"></form>
202<form action="bad://session-trans-sid.com/bar.php" method="get"></form>
203<form action="//www.session-trans-sid.com/bar.php" method="get"></form>
204
205<form action="//url-rewriter.com/bar.php" method="get"><input type="hidden" name="&lt;NAME&gt;" value="&lt;VALUE&gt;" /><input type="hidden" name="&lt;name2&gt;" value="&lt;value2&gt;" /></form>
206<form action="http://url-rewriter.com/bar.php" method="get"><input type="hidden" name="&lt;NAME&gt;" value="&lt;VALUE&gt;" /><input type="hidden" name="&lt;name2&gt;" value="&lt;value2&gt;" /></form>
207<form action="bad://url-rewriter.com/bar.php" method="get"></form>
208<form action="//www.url-rewriter.com/bar.php" method="get"></form>
209