1--TEST--
2Test output_add_rewrite_var() function basic feature
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    ob_start();
11// Common setting
12ini_set('url_rewriter.hosts', 'example.com');
13ini_set('session.use_only_cookies', 1);
14ini_set('session.use_cookies', 1);
15ini_set('session.use_strict_mode', 0);
16session_id('testid');
17
18output_add_rewrite_var('<name>', '<value>');
19?>
20Without session
21<a href=""> </a>
22<a href="./foo.php"> </a>
23<a href="//php.net/foo.php"> </a>
24<a href="http://php.net/foo.php"> </a>
25<a href="bad://php.net/foo.php"> </a>
26<a href="//www.php.net/foo.php"> </a>
27
28<form method="get"> </form>
29<form action="./foo.php" method="get"> </a>
30<form action="//php.net/bar.php" method="get"> </a>
31<form action="http://php.net/bar.php" method="get"> </a>
32<form action="bad://php.net/bar.php" method="get"> </a>
33<form action="//www.php.net/bar.php" method="get"> </a>
34
35<?php
36ini_set('session.use_trans_sid', 0);
37session_start();
38output_add_rewrite_var('<name>', '<value>');
39?>
40Test use_trans_sid=0
41<a href=""> </a>
42<a href="./foo.php"> </a>
43<a href="//php.net/foo.php"> </a>
44<a href="http://php.net/foo.php"> </a>
45<a href="bad://php.net/foo.php"> </a>
46<a href="//www.php.net/foo.php"> </a>
47
48<form method="get"> </form>
49<form action="./foo.php" method="get"> </a>
50<form action="//php.net/bar.php" method="get"> </a>
51<form action="http://php.net/bar.php" method="get"> </a>
52<form action="bad://php.net/bar.php" method="get"> </a>
53<form action="//www.php.net/bar.php" method="get"> </a>
54
55<?php
56session_commit();
57ini_set('session.use_trans_sid', 1);
58output_reset_rewrite_vars();
59session_start();
60output_add_rewrite_var('<NAME>', '<VALUE>');
61?>
62Test use_trans_sid=1
63<a href=""> </a>
64<a href="./foo.php"> </a>
65<a href="//php.net/foo.php"> </a>
66<a href="http://php.net/foo.php"> </a>
67<a href="bad://php.net/foo.php"> </a>
68<a href="//www.php.net/foo.php"> </a>
69
70<form method="get"> </form>
71<form action="./foo.php" method="get"> </a>
72<form action="//php.net/bar.php" method="get"> </a>
73<form action="http://php.net/bar.php" method="get"> </a>
74<form action="bad://php.net/bar.php" method="get"> </a>
75<form action="//www.php.net/bar.php" method="get"> </a>
76--EXPECT--
77Without session
78<a href="?%3CNAME%3E=%3CVALUE%3E"> </a>
79<a href="./foo.php?%3CNAME%3E=%3CVALUE%3E"> </a>
80<a href="//php.net/foo.php"> </a>
81<a href="http://php.net/foo.php"> </a>
82<a href="bad://php.net/foo.php"> </a>
83<a href="//www.php.net/foo.php"> </a>
84
85<form method="get"><input type="hidden" name="&lt;NAME&gt;" value="&lt;VALUE&gt;" /> </form>
86<form action="./foo.php" method="get"><input type="hidden" name="&lt;NAME&gt;" value="&lt;VALUE&gt;" /> </a>
87<form action="//php.net/bar.php" method="get"> </a>
88<form action="http://php.net/bar.php" method="get"> </a>
89<form action="bad://php.net/bar.php" method="get"> </a>
90<form action="//www.php.net/bar.php" method="get"> </a>
91
92Test use_trans_sid=0
93<a href="?%3CNAME%3E=%3CVALUE%3E"> </a>
94<a href="./foo.php?%3CNAME%3E=%3CVALUE%3E"> </a>
95<a href="//php.net/foo.php"> </a>
96<a href="http://php.net/foo.php"> </a>
97<a href="bad://php.net/foo.php"> </a>
98<a href="//www.php.net/foo.php"> </a>
99
100<form method="get"> </form>
101<form action="./foo.php" method="get"><input type="hidden" name="&lt;NAME&gt;" value="&lt;VALUE&gt;" /> </a>
102<form action="//php.net/bar.php" method="get"> </a>
103<form action="http://php.net/bar.php" method="get"> </a>
104<form action="bad://php.net/bar.php" method="get"> </a>
105<form action="//www.php.net/bar.php" method="get"> </a>
106
107Test use_trans_sid=1
108<a href="?%3CNAME%3E=%3CVALUE%3E"> </a>
109<a href="./foo.php?%3CNAME%3E=%3CVALUE%3E"> </a>
110<a href="//php.net/foo.php"> </a>
111<a href="http://php.net/foo.php"> </a>
112<a href="bad://php.net/foo.php"> </a>
113<a href="//www.php.net/foo.php"> </a>
114
115<form method="get"> </form>
116<form action="./foo.php" method="get"><input type="hidden" name="&lt;NAME&gt;" value="&lt;VALUE&gt;" /> </a>
117<form action="//php.net/bar.php" method="get"> </a>
118<form action="http://php.net/bar.php" method="get"> </a>
119<form action="bad://php.net/bar.php" method="get"> </a>
120<form action="//www.php.net/bar.php" method="get"> </a>
121