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