1--TEST--
2Test parse_url() function: Parse unterminated string
3--SKIPIF--
4<?php
5if (!function_exists('zend_create_unterminated_string')) die('skip ext/test required');
6?>
7--FILE--
8<?php
9
10/*
11 * This is the same as the basic001 test, but with unterminated strings.
12 */
13
14include_once(__DIR__ . '/urls.inc');
15
16foreach ($urls as $url) {
17    echo "\n--> $url: ";
18    $str = zend_create_unterminated_string($url);
19    var_dump(parse_url($str));
20    zend_terminate_string($str);
21}
22
23echo "Done";
24?>
25--EXPECT--
26--> 64.246.30.37: array(1) {
27  ["path"]=>
28  string(12) "64.246.30.37"
29}
30
31--> http://64.246.30.37: array(2) {
32  ["scheme"]=>
33  string(4) "http"
34  ["host"]=>
35  string(12) "64.246.30.37"
36}
37
38--> http://64.246.30.37/: array(3) {
39  ["scheme"]=>
40  string(4) "http"
41  ["host"]=>
42  string(12) "64.246.30.37"
43  ["path"]=>
44  string(1) "/"
45}
46
47--> 64.246.30.37/: array(1) {
48  ["path"]=>
49  string(13) "64.246.30.37/"
50}
51
52--> 64.246.30.37:80/: array(3) {
53  ["host"]=>
54  string(12) "64.246.30.37"
55  ["port"]=>
56  int(80)
57  ["path"]=>
58  string(1) "/"
59}
60
61--> php.net: array(1) {
62  ["path"]=>
63  string(7) "php.net"
64}
65
66--> php.net/: array(1) {
67  ["path"]=>
68  string(8) "php.net/"
69}
70
71--> http://php.net: array(2) {
72  ["scheme"]=>
73  string(4) "http"
74  ["host"]=>
75  string(7) "php.net"
76}
77
78--> http://php.net/: array(3) {
79  ["scheme"]=>
80  string(4) "http"
81  ["host"]=>
82  string(7) "php.net"
83  ["path"]=>
84  string(1) "/"
85}
86
87--> www.php.net: array(1) {
88  ["path"]=>
89  string(11) "www.php.net"
90}
91
92--> www.php.net/: array(1) {
93  ["path"]=>
94  string(12) "www.php.net/"
95}
96
97--> http://www.php.net: array(2) {
98  ["scheme"]=>
99  string(4) "http"
100  ["host"]=>
101  string(11) "www.php.net"
102}
103
104--> http://www.php.net/: array(3) {
105  ["scheme"]=>
106  string(4) "http"
107  ["host"]=>
108  string(11) "www.php.net"
109  ["path"]=>
110  string(1) "/"
111}
112
113--> www.php.net:80: array(2) {
114  ["host"]=>
115  string(11) "www.php.net"
116  ["port"]=>
117  int(80)
118}
119
120--> http://www.php.net:80: array(3) {
121  ["scheme"]=>
122  string(4) "http"
123  ["host"]=>
124  string(11) "www.php.net"
125  ["port"]=>
126  int(80)
127}
128
129--> http://www.php.net:80/: array(4) {
130  ["scheme"]=>
131  string(4) "http"
132  ["host"]=>
133  string(11) "www.php.net"
134  ["port"]=>
135  int(80)
136  ["path"]=>
137  string(1) "/"
138}
139
140--> http://www.php.net/index.php: array(3) {
141  ["scheme"]=>
142  string(4) "http"
143  ["host"]=>
144  string(11) "www.php.net"
145  ["path"]=>
146  string(10) "/index.php"
147}
148
149--> www.php.net/?: array(2) {
150  ["path"]=>
151  string(12) "www.php.net/"
152  ["query"]=>
153  string(0) ""
154}
155
156--> www.php.net:80/?: array(4) {
157  ["host"]=>
158  string(11) "www.php.net"
159  ["port"]=>
160  int(80)
161  ["path"]=>
162  string(1) "/"
163  ["query"]=>
164  string(0) ""
165}
166
167--> http://www.php.net/?: array(4) {
168  ["scheme"]=>
169  string(4) "http"
170  ["host"]=>
171  string(11) "www.php.net"
172  ["path"]=>
173  string(1) "/"
174  ["query"]=>
175  string(0) ""
176}
177
178--> http://www.php.net:80/?: array(5) {
179  ["scheme"]=>
180  string(4) "http"
181  ["host"]=>
182  string(11) "www.php.net"
183  ["port"]=>
184  int(80)
185  ["path"]=>
186  string(1) "/"
187  ["query"]=>
188  string(0) ""
189}
190
191--> http://www.php.net:80/index.php: array(4) {
192  ["scheme"]=>
193  string(4) "http"
194  ["host"]=>
195  string(11) "www.php.net"
196  ["port"]=>
197  int(80)
198  ["path"]=>
199  string(10) "/index.php"
200}
201
202--> http://www.php.net:80/foo/bar/index.php: array(4) {
203  ["scheme"]=>
204  string(4) "http"
205  ["host"]=>
206  string(11) "www.php.net"
207  ["port"]=>
208  int(80)
209  ["path"]=>
210  string(18) "/foo/bar/index.php"
211}
212
213--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php: array(4) {
214  ["scheme"]=>
215  string(4) "http"
216  ["host"]=>
217  string(11) "www.php.net"
218  ["port"]=>
219  int(80)
220  ["path"]=>
221  string(53) "/this/is/a/very/deep/directory/structure/and/file.php"
222}
223
224--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php?lots=1&of=2&parameters=3&too=4&here=5: array(5) {
225  ["scheme"]=>
226  string(4) "http"
227  ["host"]=>
228  string(11) "www.php.net"
229  ["port"]=>
230  int(80)
231  ["path"]=>
232  string(53) "/this/is/a/very/deep/directory/structure/and/file.php"
233  ["query"]=>
234  string(37) "lots=1&of=2&parameters=3&too=4&here=5"
235}
236
237--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/: array(4) {
238  ["scheme"]=>
239  string(4) "http"
240  ["host"]=>
241  string(11) "www.php.net"
242  ["port"]=>
243  int(80)
244  ["path"]=>
245  string(45) "/this/is/a/very/deep/directory/structure/and/"
246}
247
248--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php: array(4) {
249  ["scheme"]=>
250  string(4) "http"
251  ["host"]=>
252  string(11) "www.php.net"
253  ["port"]=>
254  int(80)
255  ["path"]=>
256  string(53) "/this/is/a/very/deep/directory/structure/and/file.php"
257}
258
259--> http://www.php.net:80/this/../a/../deep/directory: array(4) {
260  ["scheme"]=>
261  string(4) "http"
262  ["host"]=>
263  string(11) "www.php.net"
264  ["port"]=>
265  int(80)
266  ["path"]=>
267  string(28) "/this/../a/../deep/directory"
268}
269
270--> http://www.php.net:80/this/../a/../deep/directory/: array(4) {
271  ["scheme"]=>
272  string(4) "http"
273  ["host"]=>
274  string(11) "www.php.net"
275  ["port"]=>
276  int(80)
277  ["path"]=>
278  string(29) "/this/../a/../deep/directory/"
279}
280
281--> http://www.php.net:80/this/is/a/very/deep/directory/../file.php: array(4) {
282  ["scheme"]=>
283  string(4) "http"
284  ["host"]=>
285  string(11) "www.php.net"
286  ["port"]=>
287  int(80)
288  ["path"]=>
289  string(42) "/this/is/a/very/deep/directory/../file.php"
290}
291
292--> http://www.php.net:80/index.php: array(4) {
293  ["scheme"]=>
294  string(4) "http"
295  ["host"]=>
296  string(11) "www.php.net"
297  ["port"]=>
298  int(80)
299  ["path"]=>
300  string(10) "/index.php"
301}
302
303--> http://www.php.net:80/index.php?: array(5) {
304  ["scheme"]=>
305  string(4) "http"
306  ["host"]=>
307  string(11) "www.php.net"
308  ["port"]=>
309  int(80)
310  ["path"]=>
311  string(10) "/index.php"
312  ["query"]=>
313  string(0) ""
314}
315
316--> http://www.php.net:80/#foo: array(5) {
317  ["scheme"]=>
318  string(4) "http"
319  ["host"]=>
320  string(11) "www.php.net"
321  ["port"]=>
322  int(80)
323  ["path"]=>
324  string(1) "/"
325  ["fragment"]=>
326  string(3) "foo"
327}
328
329--> http://www.php.net:80/?#: array(6) {
330  ["scheme"]=>
331  string(4) "http"
332  ["host"]=>
333  string(11) "www.php.net"
334  ["port"]=>
335  int(80)
336  ["path"]=>
337  string(1) "/"
338  ["query"]=>
339  string(0) ""
340  ["fragment"]=>
341  string(0) ""
342}
343
344--> http://www.php.net:80/?test=1: array(5) {
345  ["scheme"]=>
346  string(4) "http"
347  ["host"]=>
348  string(11) "www.php.net"
349  ["port"]=>
350  int(80)
351  ["path"]=>
352  string(1) "/"
353  ["query"]=>
354  string(6) "test=1"
355}
356
357--> http://www.php.net/?test=1&: array(4) {
358  ["scheme"]=>
359  string(4) "http"
360  ["host"]=>
361  string(11) "www.php.net"
362  ["path"]=>
363  string(1) "/"
364  ["query"]=>
365  string(7) "test=1&"
366}
367
368--> http://www.php.net:80/?&: array(5) {
369  ["scheme"]=>
370  string(4) "http"
371  ["host"]=>
372  string(11) "www.php.net"
373  ["port"]=>
374  int(80)
375  ["path"]=>
376  string(1) "/"
377  ["query"]=>
378  string(1) "&"
379}
380
381--> http://www.php.net:80/index.php?test=1&: array(5) {
382  ["scheme"]=>
383  string(4) "http"
384  ["host"]=>
385  string(11) "www.php.net"
386  ["port"]=>
387  int(80)
388  ["path"]=>
389  string(10) "/index.php"
390  ["query"]=>
391  string(7) "test=1&"
392}
393
394--> http://www.php.net/index.php?&: array(4) {
395  ["scheme"]=>
396  string(4) "http"
397  ["host"]=>
398  string(11) "www.php.net"
399  ["path"]=>
400  string(10) "/index.php"
401  ["query"]=>
402  string(1) "&"
403}
404
405--> http://www.php.net:80/index.php?foo&: array(5) {
406  ["scheme"]=>
407  string(4) "http"
408  ["host"]=>
409  string(11) "www.php.net"
410  ["port"]=>
411  int(80)
412  ["path"]=>
413  string(10) "/index.php"
414  ["query"]=>
415  string(4) "foo&"
416}
417
418--> http://www.php.net/index.php?&foo: array(4) {
419  ["scheme"]=>
420  string(4) "http"
421  ["host"]=>
422  string(11) "www.php.net"
423  ["path"]=>
424  string(10) "/index.php"
425  ["query"]=>
426  string(4) "&foo"
427}
428
429--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI: array(5) {
430  ["scheme"]=>
431  string(4) "http"
432  ["host"]=>
433  string(11) "www.php.net"
434  ["port"]=>
435  int(80)
436  ["path"]=>
437  string(10) "/index.php"
438  ["query"]=>
439  string(31) "test=1&test2=char&test3=mixesCI"
440}
441
442--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(5) {
443  ["host"]=>
444  string(11) "www.php.net"
445  ["port"]=>
446  int(80)
447  ["path"]=>
448  string(10) "/index.php"
449  ["query"]=>
450  string(31) "test=1&test2=char&test3=mixesCI"
451  ["fragment"]=>
452  string(16) "some_page_ref123"
453}
454
455--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
456  ["scheme"]=>
457  string(4) "http"
458  ["host"]=>
459  string(11) "www.php.net"
460  ["port"]=>
461  int(80)
462  ["user"]=>
463  string(6) "secret"
464  ["path"]=>
465  string(10) "/index.php"
466  ["query"]=>
467  string(31) "test=1&test2=char&test3=mixesCI"
468  ["fragment"]=>
469  string(16) "some_page_ref123"
470}
471
472--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
473  ["scheme"]=>
474  string(4) "http"
475  ["host"]=>
476  string(11) "www.php.net"
477  ["user"]=>
478  string(6) "secret"
479  ["pass"]=>
480  string(0) ""
481  ["path"]=>
482  string(10) "/index.php"
483  ["query"]=>
484  string(31) "test=1&test2=char&test3=mixesCI"
485  ["fragment"]=>
486  string(16) "some_page_ref123"
487}
488
489--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(8) {
490  ["scheme"]=>
491  string(4) "http"
492  ["host"]=>
493  string(11) "www.php.net"
494  ["port"]=>
495  int(80)
496  ["user"]=>
497  string(0) ""
498  ["pass"]=>
499  string(7) "hideout"
500  ["path"]=>
501  string(10) "/index.php"
502  ["query"]=>
503  string(31) "test=1&test2=char&test3=mixesCI"
504  ["fragment"]=>
505  string(16) "some_page_ref123"
506}
507
508--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
509  ["scheme"]=>
510  string(4) "http"
511  ["host"]=>
512  string(11) "www.php.net"
513  ["user"]=>
514  string(6) "secret"
515  ["pass"]=>
516  string(7) "hideout"
517  ["path"]=>
518  string(10) "/index.php"
519  ["query"]=>
520  string(31) "test=1&test2=char&test3=mixesCI"
521  ["fragment"]=>
522  string(16) "some_page_ref123"
523}
524
525--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
526  ["scheme"]=>
527  string(4) "http"
528  ["host"]=>
529  string(11) "www.php.net"
530  ["port"]=>
531  int(80)
532  ["user"]=>
533  string(14) "secret@hideout"
534  ["path"]=>
535  string(10) "/index.php"
536  ["query"]=>
537  string(31) "test=1&test2=char&test3=mixesCI"
538  ["fragment"]=>
539  string(16) "some_page_ref123"
540}
541
542--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(8) {
543  ["scheme"]=>
544  string(4) "http"
545  ["host"]=>
546  string(11) "www.php.net"
547  ["port"]=>
548  int(80)
549  ["user"]=>
550  string(6) "secret"
551  ["pass"]=>
552  string(7) "hid:out"
553  ["path"]=>
554  string(10) "/index.php"
555  ["query"]=>
556  string(31) "test=1&test2=char&test3=mixesCI"
557  ["fragment"]=>
558  string(16) "some_page_ref123"
559}
560
561--> nntp://news.php.net: array(2) {
562  ["scheme"]=>
563  string(4) "nntp"
564  ["host"]=>
565  string(12) "news.php.net"
566}
567
568--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz: array(3) {
569  ["scheme"]=>
570  string(3) "ftp"
571  ["host"]=>
572  string(11) "ftp.gnu.org"
573  ["path"]=>
574  string(22) "/gnu/glic/glibc.tar.gz"
575}
576
577--> zlib:http://foo@bar: array(2) {
578  ["scheme"]=>
579  string(4) "zlib"
580  ["path"]=>
581  string(14) "http://foo@bar"
582}
583
584--> zlib:filename.txt: array(2) {
585  ["scheme"]=>
586  string(4) "zlib"
587  ["path"]=>
588  string(12) "filename.txt"
589}
590
591--> zlib:/path/to/my/file/file.txt: array(2) {
592  ["scheme"]=>
593  string(4) "zlib"
594  ["path"]=>
595  string(25) "/path/to/my/file/file.txt"
596}
597
598--> foo://foo@bar: array(3) {
599  ["scheme"]=>
600  string(3) "foo"
601  ["host"]=>
602  string(3) "bar"
603  ["user"]=>
604  string(3) "foo"
605}
606
607--> mailto:me@mydomain.com: array(2) {
608  ["scheme"]=>
609  string(6) "mailto"
610  ["path"]=>
611  string(15) "me@mydomain.com"
612}
613
614--> /foo.php?a=b&c=d: array(2) {
615  ["path"]=>
616  string(8) "/foo.php"
617  ["query"]=>
618  string(7) "a=b&c=d"
619}
620
621--> foo.php?a=b&c=d: array(2) {
622  ["path"]=>
623  string(7) "foo.php"
624  ["query"]=>
625  string(7) "a=b&c=d"
626}
627
628--> http://user:passwd@www.example.com:8080?bar=1&boom=0: array(6) {
629  ["scheme"]=>
630  string(4) "http"
631  ["host"]=>
632  string(15) "www.example.com"
633  ["port"]=>
634  int(8080)
635  ["user"]=>
636  string(4) "user"
637  ["pass"]=>
638  string(6) "passwd"
639  ["query"]=>
640  string(12) "bar=1&boom=0"
641}
642
643--> http://user_me-you:my_pas-word@www.example.com:8080?bar=1&boom=0: array(6) {
644  ["scheme"]=>
645  string(4) "http"
646  ["host"]=>
647  string(15) "www.example.com"
648  ["port"]=>
649  int(8080)
650  ["user"]=>
651  string(11) "user_me-you"
652  ["pass"]=>
653  string(11) "my_pas-word"
654  ["query"]=>
655  string(12) "bar=1&boom=0"
656}
657
658--> file:///path/to/file: array(2) {
659  ["scheme"]=>
660  string(4) "file"
661  ["path"]=>
662  string(13) "/path/to/file"
663}
664
665--> file://path/to/file: array(3) {
666  ["scheme"]=>
667  string(4) "file"
668  ["host"]=>
669  string(4) "path"
670  ["path"]=>
671  string(8) "/to/file"
672}
673
674--> file:/path/to/file: array(2) {
675  ["scheme"]=>
676  string(4) "file"
677  ["path"]=>
678  string(13) "/path/to/file"
679}
680
681--> http://1.2.3.4:/abc.asp?a=1&b=2: array(4) {
682  ["scheme"]=>
683  string(4) "http"
684  ["host"]=>
685  string(7) "1.2.3.4"
686  ["path"]=>
687  string(8) "/abc.asp"
688  ["query"]=>
689  string(7) "a=1&b=2"
690}
691
692--> http://foo.com#bar: array(3) {
693  ["scheme"]=>
694  string(4) "http"
695  ["host"]=>
696  string(7) "foo.com"
697  ["fragment"]=>
698  string(3) "bar"
699}
700
701--> scheme:: array(1) {
702  ["scheme"]=>
703  string(6) "scheme"
704}
705
706--> foo+bar://baz@bang/bla: array(4) {
707  ["scheme"]=>
708  string(7) "foo+bar"
709  ["host"]=>
710  string(4) "bang"
711  ["user"]=>
712  string(3) "baz"
713  ["path"]=>
714  string(4) "/bla"
715}
716
717--> gg:9130731: array(2) {
718  ["scheme"]=>
719  string(2) "gg"
720  ["path"]=>
721  string(7) "9130731"
722}
723
724--> http://user:@pass@host/path?argument?value#etc: array(7) {
725  ["scheme"]=>
726  string(4) "http"
727  ["host"]=>
728  string(4) "host"
729  ["user"]=>
730  string(4) "user"
731  ["pass"]=>
732  string(5) "@pass"
733  ["path"]=>
734  string(5) "/path"
735  ["query"]=>
736  string(14) "argument?value"
737  ["fragment"]=>
738  string(3) "etc"
739}
740
741--> http://10.10.10.10/:80: array(3) {
742  ["scheme"]=>
743  string(4) "http"
744  ["host"]=>
745  string(11) "10.10.10.10"
746  ["path"]=>
747  string(4) "/:80"
748}
749
750--> http://x:?: array(3) {
751  ["scheme"]=>
752  string(4) "http"
753  ["host"]=>
754  string(1) "x"
755  ["query"]=>
756  string(0) ""
757}
758
759--> x:blah.com: array(2) {
760  ["scheme"]=>
761  string(1) "x"
762  ["path"]=>
763  string(8) "blah.com"
764}
765
766--> x:/blah.com: array(2) {
767  ["scheme"]=>
768  string(1) "x"
769  ["path"]=>
770  string(9) "/blah.com"
771}
772
773--> x://::abc/?: bool(false)
774
775--> http://::?: array(3) {
776  ["scheme"]=>
777  string(4) "http"
778  ["host"]=>
779  string(1) ":"
780  ["query"]=>
781  string(0) ""
782}
783
784--> http://::#: array(3) {
785  ["scheme"]=>
786  string(4) "http"
787  ["host"]=>
788  string(1) ":"
789  ["fragment"]=>
790  string(0) ""
791}
792
793--> x://::6.5: array(3) {
794  ["scheme"]=>
795  string(1) "x"
796  ["host"]=>
797  string(1) ":"
798  ["port"]=>
799  int(6)
800}
801
802--> http://?:/: bool(false)
803
804--> http://@?:/: bool(false)
805
806--> file:///:: array(2) {
807  ["scheme"]=>
808  string(4) "file"
809  ["path"]=>
810  string(2) "/:"
811}
812
813--> file:///a:/: array(2) {
814  ["scheme"]=>
815  string(4) "file"
816  ["path"]=>
817  string(3) "a:/"
818}
819
820--> file:///ab:/: array(2) {
821  ["scheme"]=>
822  string(4) "file"
823  ["path"]=>
824  string(5) "/ab:/"
825}
826
827--> file:///a:/: array(2) {
828  ["scheme"]=>
829  string(4) "file"
830  ["path"]=>
831  string(3) "a:/"
832}
833
834--> file:///@:/: array(2) {
835  ["scheme"]=>
836  string(4) "file"
837  ["path"]=>
838  string(3) "@:/"
839}
840
841--> file:///:80/: array(2) {
842  ["scheme"]=>
843  string(4) "file"
844  ["path"]=>
845  string(5) "/:80/"
846}
847
848--> []: array(1) {
849  ["path"]=>
850  string(2) "[]"
851}
852
853--> http://[x:80]/: array(3) {
854  ["scheme"]=>
855  string(4) "http"
856  ["host"]=>
857  string(6) "[x:80]"
858  ["path"]=>
859  string(1) "/"
860}
861
862--> : array(1) {
863  ["path"]=>
864  string(0) ""
865}
866
867--> /: array(1) {
868  ["path"]=>
869  string(1) "/"
870}
871
872--> /rest/Users?filter={"id":"123"}: array(2) {
873  ["path"]=>
874  string(11) "/rest/Users"
875  ["query"]=>
876  string(19) "filter={"id":"123"}"
877}
878
879--> %:x: array(1) {
880  ["path"]=>
881  string(3) "%:x"
882}
883
884--> https://example.com:0/: array(4) {
885  ["scheme"]=>
886  string(5) "https"
887  ["host"]=>
888  string(11) "example.com"
889  ["port"]=>
890  int(0)
891  ["path"]=>
892  string(1) "/"
893}
894
895--> http:///blah.com: bool(false)
896
897--> http://:80: bool(false)
898
899--> http://user@:80: bool(false)
900
901--> http://user:pass@:80: bool(false)
902
903--> http://:: bool(false)
904
905--> http://@/: bool(false)
906
907--> http://@:/: bool(false)
908
909--> http://:/: bool(false)
910
911--> http://?: bool(false)
912
913--> http://#: bool(false)
914
915--> http://?:: bool(false)
916
917--> http://:?: bool(false)
918
919--> http://blah.com:123456: bool(false)
920
921--> http://blah.com:abcdef: bool(false)
922Done
923