Merge branch 'v2.6.x'
[m6w6/ext-http] / tests / gh-issue48.phpt
1 --TEST--
2 url errors
3 --SKIPIF--
4 <?php
5 include "skipif.inc";
6 ?>
7 --FILE--
8 <?php
9 echo "Test\n";
10
11 function test($url, $flags = 0) {
12 echo "# DEFAULT\n";
13 try {
14 echo new http\Url($url, null, $flags), "\n";
15 } catch (Exception $e) {
16 echo $e->getMessage(), "\n";
17 }
18
19 echo "# IGNORE\n";
20 echo new http\Url($url, null, $flags|http\Url::IGNORE_ERRORS), "\n";
21
22 echo "# SILENT\n";
23 echo new http\Url($url, null, $flags|http\Url::SILENT_ERRORS), "\n";
24
25 echo "# IGNORE|SILENT\n";
26 echo new http\Url($url, null, $flags|http\Url::IGNORE_ERRORS|http\Url::SILENT_ERRORS), "\n";
27 echo "==========\n";
28 }
29
30 test("http://.foo.bar/?q=1");
31 test("http://..foo.bar/i.x");
32 test("http://foo..bar/i..x");
33 test("http://-foo.bar");
34 test("http://--foo.bar");
35 test("http://f--oo.bar");
36 test("htto://foo.bar/?q=%");
37 test("htto://foo.bar/?q=%", http\Url::PARSE_TOPCT);
38 test("http://a\xc3\xc3b");
39 test("http://[foobar]:123");
40 test("#/?foo=&#", http\Url::PARSE_MBUTF8);
41
42 ?>
43
44 ===DONE===
45 --EXPECTF--
46 Test
47 # DEFAULT
48 http\Url::__construct(): Failed to parse host; unexpected '.' at pos 0 in '.foo.bar/?q=1'
49 # IGNORE
50
51 Warning: http\Url::__construct(): Failed to parse host; unexpected '.' at pos 0 in '.foo.bar/?q=1' in %sgh-issue48.php on line %d
52 http://foo.bar/?q=1
53 # SILENT
54
55 # IGNORE|SILENT
56 http://foo.bar/?q=1
57 ==========
58 # DEFAULT
59 http\Url::__construct(): Failed to parse host; unexpected '.' at pos 0 in '..foo.bar/i.x'
60 # IGNORE
61
62 Warning: http\Url::__construct(): Failed to parse host; unexpected '.' at pos 0 in '..foo.bar/i.x' in %sgh-issue48.php on line %d
63
64 Warning: http\Url::__construct(): Failed to parse host; unexpected '.' at pos 1 in '..foo.bar/i.x' in %sgh-issue48.php on line %d
65 http://foo.bar/i.x
66 # SILENT
67
68 # IGNORE|SILENT
69 http://foo.bar/i.x
70 ==========
71 # DEFAULT
72 http\Url::__construct(): Failed to parse host; unexpected '.' at pos 4 in 'foo..bar/i..x'
73 # IGNORE
74
75 Warning: http\Url::__construct(): Failed to parse host; unexpected '.' at pos 4 in 'foo..bar/i..x' in %sgh-issue48.php on line %d
76 http://foo.bar/i..x
77 # SILENT
78
79 # IGNORE|SILENT
80 http://foo.bar/i..x
81 ==========
82 # DEFAULT
83 http\Url::__construct(): Failed to parse host; unexpected '-' at pos 0 in '-foo.bar'
84 # IGNORE
85
86 Warning: http\Url::__construct(): Failed to parse host; unexpected '-' at pos 0 in '-foo.bar' in %sgh-issue48.php on line %d
87 http://foo.bar/
88 # SILENT
89
90 # IGNORE|SILENT
91 http://foo.bar/
92 ==========
93 # DEFAULT
94 http\Url::__construct(): Failed to parse host; unexpected '-' at pos 0 in '--foo.bar'
95 # IGNORE
96
97 Warning: http\Url::__construct(): Failed to parse host; unexpected '-' at pos 0 in '--foo.bar' in %sgh-issue48.php on line %d
98
99 Warning: http\Url::__construct(): Failed to parse host; unexpected '-' at pos 1 in '--foo.bar' in %sgh-issue48.php on line %d
100 http://foo.bar/
101 # SILENT
102
103 # IGNORE|SILENT
104 http://foo.bar/
105 ==========
106 # DEFAULT
107 http://f--oo.bar/
108 # IGNORE
109 http://f--oo.bar/
110 # SILENT
111 http://f--oo.bar/
112 # IGNORE|SILENT
113 http://f--oo.bar/
114 ==========
115 # DEFAULT
116 http\Url::__construct(): Failed to parse query; invalid percent encoding at pos 2 in 'q=%'
117 # IGNORE
118
119 Warning: http\Url::__construct(): Failed to parse query; invalid percent encoding at pos 2 in 'q=%' in %sgh-issue48.php on line %d
120 htto://foo.bar/?q=%
121 # SILENT
122
123 # IGNORE|SILENT
124 htto://foo.bar/?q=%
125 ==========
126 # DEFAULT
127 http\Url::__construct(): Failed to parse query; invalid percent encoding at pos 2 in 'q=%'
128 # IGNORE
129
130 Warning: http\Url::__construct(): Failed to parse query; invalid percent encoding at pos 2 in 'q=%' in %sgh-issue48.php on line %d
131 htto://foo.bar/?q=%25
132 # SILENT
133
134 # IGNORE|SILENT
135 htto://foo.bar/?q=%25
136 ==========
137 # DEFAULT
138 http\Url::__construct(): Failed to parse hostinfo; unexpected byte 0xc3 at pos 1 in 'a%c%cb'
139 # IGNORE
140
141 Warning: http\Url::__construct(): Failed to parse hostinfo; unexpected byte 0xc3 at pos 1 in 'a%c%cb' in %sgh-issue48.php on line %d
142
143 Warning: http\Url::__construct(): Failed to parse hostinfo; unexpected byte 0xc3 at pos 2 in 'a%c%cb' in %sgh-issue48.php on line %d
144 http://ab/
145 # SILENT
146
147 # IGNORE|SILENT
148 http://ab/
149 ==========
150 # DEFAULT
151 http\Url::__construct(): Failed to parse hostinfo; unexpected '[' at pos 0 in '[foobar]:123'
152 # IGNORE
153
154 Warning: http\Url::__construct(): Failed to parse hostinfo; unexpected '[' at pos 0 in '[foobar]:123' in %sgh-issue48.php on line %d
155
156 Warning: http\Url::__construct(): Failed to parse hostinfo; unexpected byte 0x5b at pos 0 in '[foobar]:123' in %sgh-issue48.php on line %d
157
158 Warning: http\Url::__construct(): Failed to parse hostinfo; unexpected byte 0x5d at pos 7 in '[foobar]:123' in %sgh-issue48.php on line %d
159 http://foobar:123/
160 # SILENT
161
162 # IGNORE|SILENT
163 http://foobar:123/
164 ==========
165 # DEFAULT
166 http\Url::__construct(): Failed to parse fragment; invalid fragment identifier at pos 7 in '/?foo=&#'
167 # IGNORE
168
169 Warning: http\Url::__construct(): Failed to parse fragment; invalid fragment identifier at pos 7 in '/?foo=&#' in %sgh-issue48.php on line %d
170 #/?foo=&#
171 # SILENT
172
173 # IGNORE|SILENT
174 #/?foo=&#
175 ==========
176
177 ===DONE===