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