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