1--TEST--
2Test basic function : variation3 use_trans_sid
3--INI--
4session.use_strict_mode=0
5session.use_only_cookies=0
6session.use_trans_sid=1
7session.save_handler=files
8session.hash_bits_per_character=4
9session.hash_function=0
10session.gc_probability=1
11session.gc_divisor=1000
12session.gc_maxlifetime=300
13session.save_path=
14session.name=PHPSESSID
15--XFAIL--
16Waiting url_scanner_ex.re fix. https://bugs.php.net/bug.php?id=68970
17--SKIPIF--
18<?php include('skipif.inc'); ?>
19--FILE--
20<?php
21
22ob_start();
23
24/*
25 * Prototype : session.use_trans_sid=1
26 * Description : Test basic functionality.
27 * Source code : ext/session/session.c
28 */
29
30echo "*** Testing basic session functionality : variation3 use_trans_sid ***\n";
31
32/*
33echo "*** test output_add_rewrite_var() ***\n";
34output_add_rewrite_var('var', 'value');
35echo '
36<a href="/">test</a>
37<a href="/#bar">test</a>
38<a href="/?foo">test</a>
39<a href="/?foo#bar">test</a>
40<a href="/?foo=var">test</a>
41<a href="/?foo=var#bar">test</a>
42<a href="file.php">test</a>
43<a href="file.php?foo">test</a>
44<a href="file.php?foo=var">test</a>
45<a href="http://php.net">test</a>
46<a href="http://php.net/">test</a>
47<a href="http://php.net/#bar">test</a>
48<a href="http://php.net/?foo">test</a>
49<a href="http://php.net/?foo#bar">test</a>
50<a href="http://php.net/?foo=var">test</a>
51<a href="http://php.net/?foo=var#bar">test</a>
52<a href="http://php.net/file.php">test</a>
53<a href="http://php.net/file.php#bar">test</a>
54<a href="http://php.net/file.php?foo">test</a>
55<a href="http://php.net/file.php?foo#bar">test</a>
56<a href="http://php.net/file.php?foo=var">test</a>
57<a href="http://php.net/file.php?foo=var#bar">test</a>
58<a href="http://php.net/some/path/file.php">test</a>
59<a href="http://php.net/some/path/file.php?foo">test</a>
60<a href="http://php.net/some/path/file.php?foo=var">test</a>
61<a href="http://php.net/some/path/file.php?foo=var#bar">test</a>
62<a href="https://php.net">test</a>
63<a href="https://php.net/">test</a>
64<a href="https://php.net/?foo=var#bar">test</a>
65<a href="https://php.net/file.php">test</a>
66<a href="https://php.net/file.php?foo=var#bar">test</a>
67<a href="https://php.net/some/path/file.php">test</a>
68<a href="https://php.net/some/path/file.php?foo=var#bar">test</a>
69<a href="https://php.net:8443">test</a>
70<a href="https://php.net:8443/">test</a>
71<a href="https://php.net:8443/?foo=var#bar">test</a>
72<a href="https://php.net:8443/file.php">test</a>
73<a href="https://php.net:8443/file.php?foo=var#bar">test</a>
74<a href="https://php.net:8443/some/path/file.php">test</a>
75<a href="https://php.net:8443/some/path/file.php?foo=var#bar">test</a>
76<a href="//php.net">test</a>
77<a href="//php.net/">test</a>
78<a href="//php.net/#bar">test</a>
79<a href="//php.net/?foo">test</a>
80<a href="//php.net/?foo#bar">test</a>
81<a href="//php.net/?foo=var">test</a>
82<a href="//php.net/?foo=var#bar">test</a>
83<a href="//php.net/file.php">test</a>
84<a href="//php.net/file.php#bar">test</a>
85<a href="//php.net/file.php?foo">test</a>
86<a href="//php.net/file.php?foo#bar">test</a>
87<a href="//php.net/file.php?foo=var">test</a>
88<a href="//php.net/file.php?foo=var#bar">test</a>
89<a href="//php.net/some/path/file.php">test</a>
90<a href="//php.net/some/path/file.php?foo">test</a>
91<a href="//php.net/some/path/file.php?foo=var">test</a>
92<a href="//php.net/some/path/file.php?foo=var#bar">test</a>
93<form action="script.php" method="post">
94  <input type="text" name="test1"></input>
95  <input type="text" name="test2" />
96</form>
97';
98output_reset_rewrite_vars();
99*/
100
101echo "*** Test trans sid ***\n";
102ob_start();
103$session_id = 'testid';
104session_id($session_id);
105session_start();
106// Should add session ID to relative URL only for SECURITY
107echo '
108<a href="/">test</a>
109<a href="/path">test</a>
110<a href="/path/">test</a>
111<a href="/path/?foo=var">test</a>
112<a href="../">test</a>
113<a href="../path">test</a>
114<a href="../path/">test</a>
115<a href="../path/?foo=var">test</a>
116
117<a href="/#bar">test</a>
118<a href="/path/#bar">test</a>
119<a href="/path/?foo=var#bar">test</a>
120<a href="../#bar">test</a>
121<a href="../path/#bar">test</a>
122<a href="../path/?foo=var#bar">test</a>
123
124<a href="/?foo">test</a>
125<a href="/?foo#bar">test</a>
126<a href="/?foo=var">test</a>
127<a href="/?foo=var#bar">test</a>
128<a href="../?foo">test</a>
129<a href="../?foo#bar">test</a>
130<a href="../?foo=var">test</a>
131<a href="../?foo=var#bar">test</a>
132
133<a href="file.php">test</a>
134<a href="file.php?foo">test</a>
135<a href="file.php?foo=var">test</a>
136<a href="file.php?foo=var#bar">test</a>
137<a href="../file.php">test</a>
138<a href="../file.php?foo">test</a>
139<a href="../file.php?foo=var">test</a>
140<a href="../file.php?foo=var#bar">test</a>
141
142<a href="http://php.net">test</a>
143<a href="http://php.net/">test</a>
144<a href="http://php.net/#bar">test</a>
145<a href="http://php.net/?foo">test</a>
146<a href="http://php.net/?foo#bar">test</a>
147<a href="http://php.net/?foo=var">test</a>
148<a href="http://php.net/?foo=var#bar">test</a>
149<a href="http://php.net/file.php">test</a>
150<a href="http://php.net/file.php#bar">test</a>
151<a href="http://php.net/file.php?foo">test</a>
152<a href="http://php.net/file.php?foo#bar">test</a>
153<a href="http://php.net/file.php?foo=var">test</a>
154<a href="http://php.net/file.php?foo=var#bar">test</a>
155<a href="http://php.net/some/path/file.php">test</a>
156<a href="http://php.net/some/path/file.php?foo">test</a>
157<a href="http://php.net/some/path/file.php?foo=var">test</a>
158<a href="http://php.net/some/path/file.php?foo=var#bar">test</a>
159
160<a href="https://php.net">test</a>
161<a href="https://php.net/">test</a>
162<a href="https://php.net/?foo=var#bar">test</a>
163<a href="https://php.net/file.php">test</a>
164<a href="https://php.net/file.php?foo=var#bar">test</a>
165<a href="https://php.net/some/path/file.php">test</a>
166<a href="https://php.net/some/path/file.php?foo=var#bar">test</a>
167<a href="https://php.net:8443">test</a>
168<a href="https://php.net:8443/">test</a>
169<a href="https://php.net:8443/?foo=var#bar">test</a>
170<a href="https://php.net:8443/file.php">test</a>
171<a href="https://php.net:8443/file.php?foo=var#bar">test</a>
172<a href="https://php.net:8443/some/path/file.php">test</a>
173<a href="https://php.net:8443/some/path/file.php?foo=var#bar">test</a>
174
175<a href="//php.net">test</a>
176<a href="//php.net/">test</a>
177<a href="//php.net/#bar">test</a>
178<a href="//php.net/?foo">test</a>
179<a href="//php.net/?foo#bar">test</a>
180<a href="//php.net/?foo=var">test</a>
181<a href="//php.net/?foo=var#bar">test</a>
182<a href="//php.net/file.php">test</a>
183<a href="//php.net/file.php#bar">test</a>
184<a href="//php.net/file.php?foo">test</a>
185<a href="//php.net/file.php?foo#bar">test</a>
186<a href="//php.net/file.php?foo=var">test</a>
187<a href="//php.net/file.php?foo=var#bar">test</a>
188<a href="//php.net/some/path/file.php">test</a>
189<a href="//php.net/some/path/file.php?foo">test</a>
190<a href="//php.net/some/path/file.php?foo=var">test</a>
191<a href="//php.net/some/path/file.php?foo=var#bar">test</a>
192
193<form action="script.php" method="post">
194  <input type="text" name="test1"></input>
195  <input type="text" name="test2" />
196</form>
197<form action="../script.php" method="post">
198  <input type="text" name="test1"></input>
199  <input type="text" name="test2" />
200</form>
201<form action="/path/script.php" method="post">
202  <input type="text" name="test1"></input>
203  <input type="text" name="test2" />
204</form>
205<form action="../path/script.php" method="post">
206  <input type="text" name="test1"></input>
207  <input type="text" name="test2" />
208</form>
209<form action="http://php.net/script.php" method="post">
210  <input type="text" name="test1"></input>
211  <input type="text" name="test2" />
212</form>
213<form action="https://php.net/script.php" method="post">
214  <input type="text" name="test1"></input>
215  <input type="text" name="test2" />
216</form>
217<form action="//php.net/script.php" method="post">
218  <input type="text" name="test1"></input>
219  <input type="text" name="test2" />
220</form>
221';
222var_dump(session_commit());
223
224echo "*** Cleanup ***\n";
225var_dump(session_start());
226var_dump(session_id());
227var_dump(session_destroy());
228
229ob_end_flush();
230?>
231--EXPECT--
232*** Testing basic session functionality : variation3 use_trans_sid ***
233*** Test trans sid ***
234
235<a href="/?PHPSESSID=testid">test</a>
236<a href="/?PHPSESSID=testid#bar">test</a>
237<a href="/?foo&PHPSESSID=testid">test</a>
238<a href="/?foo&PHPSESSID=testid#bar">test</a>
239<a href="/?foo=var&PHPSESSID=testid">test</a>
240<a href="/?foo=var&PHPSESSID=testid#bar">test</a>
241<a href="file.php?PHPSESSID=testid">test</a>
242<a href="file.php?foo&PHPSESSID=testid">test</a>
243<a href="file.php?foo=var&PHPSESSID=testid">test</a>
244<a href="/?PHPSESSID=testid">test</a>
245<a href="/path?PHPSESSID=testid">test</a>
246<a href="/path/?PHPSESSID=testid">test</a>
247<a href="/path/?foo=var&PHPSESSID=testid">test</a>
248<a href="../?PHPSESSID=testid">test</a>
249<a href="../path?PHPSESSID=testid">test</a>
250<a href="../path/?PHPSESSID=testid">test</a>
251<a href="../path/?foo=var&PHPSESSID=testid">test</a>
252
253<a href="/?PHPSESSID=testid#bar">test</a>
254<a href="/path/?PHPSESSID=testid#bar">test</a>
255<a href="/path/?foo=var&PHPSESSID=testid#bar">test</a>
256<a href="../?PHPSESSID=testid#bar">test</a>
257<a href="../path/?PHPSESSID=testid#bar">test</a>
258<a href="../path/?foo=var&PHPSESSID=testid#bar">test</a>
259
260<a href="/?foo">test</a>
261<a href="/?foo#bar">test</a>
262<a href="/?foo=var">test</a>
263<a href="/?foo=var#bar">test</a>
264<a href="../?foo">test</a>
265<a href="../?foo#bar">test</a>
266<a href="../?foo=var">test</a>
267<a href="../?foo=var#bar">test</a>
268
269<a href="http://php.net">test</a>
270<a href="http://php.net/">test</a>
271<a href="http://php.net/#bar">test</a>
272<a href="http://php.net/?foo">test</a>
273<a href="http://php.net/?foo#bar">test</a>
274<a href="http://php.net/?foo=var">test</a>
275<a href="http://php.net/?foo=var#bar">test</a>
276<a href="http://php.net/file.php">test</a>
277<a href="http://php.net/file.php#bar">test</a>
278<a href="http://php.net/file.php?foo">test</a>
279<a href="http://php.net/file.php?foo#bar">test</a>
280<a href="http://php.net/file.php?foo=var">test</a>
281<a href="http://php.net/file.php?foo=var#bar">test</a>
282<a href="http://php.net/some/path/file.php">test</a>
283<a href="http://php.net/some/path/file.php?foo">test</a>
284<a href="http://php.net/some/path/file.php?foo=var">test</a>
285<a href="http://php.net/some/path/file.php?foo=var#bar">test</a>
286
287<a href="https://php.net">test</a>
288<a href="https://php.net/">test</a>
289<a href="https://php.net/?foo=var#bar">test</a>
290<a href="https://php.net/file.php">test</a>
291<a href="https://php.net/file.php?foo=var#bar">test</a>
292<a href="https://php.net/some/path/file.php">test</a>
293<a href="https://php.net/some/path/file.php?foo=var#bar">test</a>
294<a href="https://php.net:8443">test</a>
295<a href="https://php.net:8443/">test</a>
296<a href="https://php.net:8443/?foo=var#bar">test</a>
297<a href="https://php.net:8443/file.php">test</a>
298<a href="https://php.net:8443/file.php?foo=var#bar">test</a>
299<a href="https://php.net:8443/some/path/file.php">test</a>
300<a href="https://php.net:8443/some/path/file.php?foo=var#bar">test</a>
301
302<a href="//php.net">test</a>
303<a href="//php.net/">test</a>
304<a href="//php.net/#bar">test</a>
305<a href="//php.net/?foo">test</a>
306<a href="//php.net/?foo#bar">test</a>
307<a href="//php.net/?foo=var">test</a>
308<a href="//php.net/?foo=var#bar">test</a>
309<a href="//php.net/file.php">test</a>
310<a href="//php.net/file.php#bar">test</a>
311<a href="//php.net/file.php?foo">test</a>
312<a href="//php.net/file.php?foo#bar">test</a>
313<a href="//php.net/file.php?foo=var">test</a>
314<a href="//php.net/file.php?foo=var#bar">test</a>
315<a href="//php.net/some/path/file.php">test</a>
316<a href="//php.net/some/path/file.php?foo">test</a>
317<a href="//php.net/some/path/file.php?foo=var">test</a>
318<a href="//php.net/some/path/file.php?foo=var#bar">test</a>
319
320<form action="script.php" method="post"><input type="hidden" name="PHPSESSID" value="testid" /><input type="hidden" name="PHPSESSID" value="testid" />
321  <input type="text" name="test1"></input>
322  <input type="text" name="test2" />
323</form>
324<form action="../script.php" method="post"><input type="hidden" name="PHPSESSID" value="testid" /><input type="hidden" name="PHPSESSID" value="testid" />
325  <input type="text" name="test1"></input>
326  <input type="text" name="test2" />
327</form>
328<form action="/path/script.php" method="post"><input type="hidden" name="PHPSESSID" value="testid" /><input type="hidden" name="PHPSESSID" value="testid" />
329  <input type="text" name="test1"></input>
330  <input type="text" name="test2" />
331</form>
332<form action="../path/script.php" method="post"><input type="hidden" name="PHPSESSID" value="testid" /><input type="hidden" name="PHPSESSID" value="testid" />
333  <input type="text" name="test1"></input>
334  <input type="text" name="test2" />
335</form>
336<form action="http://php.net/script.php" method="post"><input type="hidden" name="PHPSESSID" value="testid" /><input type="hidden" name="PHPSESSID" value="testid" />
337  <input type="text" name="test1"></input>
338  <input type="text" name="test2" />
339</form>
340<form action="https://php.net/script.php" method="post"><input type="hidden" name="PHPSESSID" value="testid" /><input type="hidden" name="PHPSESSID" value="testid" />
341  <input type="text" name="test1"></input>
342  <input type="text" name="test2" />
343</form>
344<form action="//php.net/script.php" method="post"><input type="hidden" name="PHPSESSID" value="testid" /><input type="hidden" name="PHPSESSID" value="testid" />
345  <input type="text" name="test1"></input>
346  <input type="text" name="test2" />
347</form>
348NULL
349*** Cleanup ***
350bool(true)
351string(6) "testid"
352bool(true)