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--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(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(7) {
512  ["scheme"]=>
513  string(4) "http"
514  ["host"]=>
515  string(11) "www.php.net"
516  ["port"]=>
517  int(80)
518  ["user"]=>
519  string(14) "secret@hideout"
520  ["path"]=>
521  string(10) "/index.php"
522  ["query"]=>
523  string(31) "test=1&test2=char&test3=mixesCI"
524  ["fragment"]=>
525  string(16) "some_page_ref123"
526}
527
528--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(8) {
529  ["scheme"]=>
530  string(4) "http"
531  ["host"]=>
532  string(11) "www.php.net"
533  ["port"]=>
534  int(80)
535  ["user"]=>
536  string(6) "secret"
537  ["pass"]=>
538  string(7) "hid:out"
539  ["path"]=>
540  string(10) "/index.php"
541  ["query"]=>
542  string(31) "test=1&test2=char&test3=mixesCI"
543  ["fragment"]=>
544  string(16) "some_page_ref123"
545}
546
547--> nntp://news.php.net: array(2) {
548  ["scheme"]=>
549  string(4) "nntp"
550  ["host"]=>
551  string(12) "news.php.net"
552}
553
554--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz: array(3) {
555  ["scheme"]=>
556  string(3) "ftp"
557  ["host"]=>
558  string(11) "ftp.gnu.org"
559  ["path"]=>
560  string(22) "/gnu/glic/glibc.tar.gz"
561}
562
563--> zlib:http://foo@bar: array(2) {
564  ["scheme"]=>
565  string(4) "zlib"
566  ["path"]=>
567  string(14) "http://foo@bar"
568}
569
570--> zlib:filename.txt: array(2) {
571  ["scheme"]=>
572  string(4) "zlib"
573  ["path"]=>
574  string(12) "filename.txt"
575}
576
577--> zlib:/path/to/my/file/file.txt: array(2) {
578  ["scheme"]=>
579  string(4) "zlib"
580  ["path"]=>
581  string(25) "/path/to/my/file/file.txt"
582}
583
584--> foo://foo@bar: array(3) {
585  ["scheme"]=>
586  string(3) "foo"
587  ["host"]=>
588  string(3) "bar"
589  ["user"]=>
590  string(3) "foo"
591}
592
593--> mailto:me@mydomain.com: array(2) {
594  ["scheme"]=>
595  string(6) "mailto"
596  ["path"]=>
597  string(15) "me@mydomain.com"
598}
599
600--> /foo.php?a=b&c=d: array(2) {
601  ["path"]=>
602  string(8) "/foo.php"
603  ["query"]=>
604  string(7) "a=b&c=d"
605}
606
607--> foo.php?a=b&c=d: array(2) {
608  ["path"]=>
609  string(7) "foo.php"
610  ["query"]=>
611  string(7) "a=b&c=d"
612}
613
614--> http://user:passwd@www.example.com:8080?bar=1&boom=0: array(6) {
615  ["scheme"]=>
616  string(4) "http"
617  ["host"]=>
618  string(15) "www.example.com"
619  ["port"]=>
620  int(8080)
621  ["user"]=>
622  string(4) "user"
623  ["pass"]=>
624  string(6) "passwd"
625  ["query"]=>
626  string(12) "bar=1&boom=0"
627}
628
629--> http://user_me-you:my_pas-word@www.example.com:8080?bar=1&boom=0: array(6) {
630  ["scheme"]=>
631  string(4) "http"
632  ["host"]=>
633  string(15) "www.example.com"
634  ["port"]=>
635  int(8080)
636  ["user"]=>
637  string(11) "user_me-you"
638  ["pass"]=>
639  string(11) "my_pas-word"
640  ["query"]=>
641  string(12) "bar=1&boom=0"
642}
643
644--> file:///path/to/file: array(2) {
645  ["scheme"]=>
646  string(4) "file"
647  ["path"]=>
648  string(13) "/path/to/file"
649}
650
651--> file://path/to/file: array(3) {
652  ["scheme"]=>
653  string(4) "file"
654  ["host"]=>
655  string(4) "path"
656  ["path"]=>
657  string(8) "/to/file"
658}
659
660--> file:/path/to/file: array(2) {
661  ["scheme"]=>
662  string(4) "file"
663  ["path"]=>
664  string(13) "/path/to/file"
665}
666
667--> http://1.2.3.4:/abc.asp?a=1&b=2: array(4) {
668  ["scheme"]=>
669  string(4) "http"
670  ["host"]=>
671  string(7) "1.2.3.4"
672  ["path"]=>
673  string(8) "/abc.asp"
674  ["query"]=>
675  string(7) "a=1&b=2"
676}
677
678--> http://foo.com#bar: array(3) {
679  ["scheme"]=>
680  string(4) "http"
681  ["host"]=>
682  string(7) "foo.com"
683  ["fragment"]=>
684  string(3) "bar"
685}
686
687--> scheme:: array(1) {
688  ["scheme"]=>
689  string(6) "scheme"
690}
691
692--> foo+bar://baz@bang/bla: array(4) {
693  ["scheme"]=>
694  string(7) "foo+bar"
695  ["host"]=>
696  string(4) "bang"
697  ["user"]=>
698  string(3) "baz"
699  ["path"]=>
700  string(4) "/bla"
701}
702
703--> gg:9130731: array(2) {
704  ["scheme"]=>
705  string(2) "gg"
706  ["path"]=>
707  string(7) "9130731"
708}
709
710--> http://user:@pass@host/path?argument?value#etc: array(7) {
711  ["scheme"]=>
712  string(4) "http"
713  ["host"]=>
714  string(4) "host"
715  ["user"]=>
716  string(4) "user"
717  ["pass"]=>
718  string(5) "@pass"
719  ["path"]=>
720  string(5) "/path"
721  ["query"]=>
722  string(14) "argument?value"
723  ["fragment"]=>
724  string(3) "etc"
725}
726
727--> http://10.10.10.10/:80: array(3) {
728  ["scheme"]=>
729  string(4) "http"
730  ["host"]=>
731  string(11) "10.10.10.10"
732  ["path"]=>
733  string(4) "/:80"
734}
735
736--> http://x:?: array(2) {
737  ["scheme"]=>
738  string(4) "http"
739  ["host"]=>
740  string(1) "x"
741}
742
743--> x:blah.com: array(2) {
744  ["scheme"]=>
745  string(1) "x"
746  ["path"]=>
747  string(8) "blah.com"
748}
749
750--> x:/blah.com: array(2) {
751  ["scheme"]=>
752  string(1) "x"
753  ["path"]=>
754  string(9) "/blah.com"
755}
756
757--> x://::abc/?: bool(false)
758
759--> http://::?: array(2) {
760  ["scheme"]=>
761  string(4) "http"
762  ["host"]=>
763  string(1) ":"
764}
765
766--> http://::#: array(2) {
767  ["scheme"]=>
768  string(4) "http"
769  ["host"]=>
770  string(1) ":"
771}
772
773--> x://::6.5: array(3) {
774  ["scheme"]=>
775  string(1) "x"
776  ["host"]=>
777  string(1) ":"
778  ["port"]=>
779  int(6)
780}
781
782--> http://?:/: bool(false)
783
784--> http://@?:/: bool(false)
785
786--> file:///:: array(2) {
787  ["scheme"]=>
788  string(4) "file"
789  ["path"]=>
790  string(2) "/:"
791}
792
793--> file:///a:/: array(2) {
794  ["scheme"]=>
795  string(4) "file"
796  ["path"]=>
797  string(3) "a:/"
798}
799
800--> file:///ab:/: array(2) {
801  ["scheme"]=>
802  string(4) "file"
803  ["path"]=>
804  string(5) "/ab:/"
805}
806
807--> file:///a:/: array(2) {
808  ["scheme"]=>
809  string(4) "file"
810  ["path"]=>
811  string(3) "a:/"
812}
813
814--> file:///@:/: array(2) {
815  ["scheme"]=>
816  string(4) "file"
817  ["path"]=>
818  string(3) "@:/"
819}
820
821--> file:///:80/: array(2) {
822  ["scheme"]=>
823  string(4) "file"
824  ["path"]=>
825  string(5) "/:80/"
826}
827
828--> []: array(1) {
829  ["path"]=>
830  string(2) "[]"
831}
832
833--> http://[x:80]/: array(3) {
834  ["scheme"]=>
835  string(4) "http"
836  ["host"]=>
837  string(6) "[x:80]"
838  ["path"]=>
839  string(1) "/"
840}
841
842--> : array(1) {
843  ["path"]=>
844  string(0) ""
845}
846
847--> /: array(1) {
848  ["path"]=>
849  string(1) "/"
850}
851
852--> /rest/Users?filter={"id":"123"}: array(2) {
853  ["path"]=>
854  string(11) "/rest/Users"
855  ["query"]=>
856  string(19) "filter={"id":"123"}"
857}
858
859--> %:x: array(1) {
860  ["path"]=>
861  string(3) "%:x"
862}
863
864--> https://example.com:0/: array(4) {
865  ["scheme"]=>
866  string(5) "https"
867  ["host"]=>
868  string(11) "example.com"
869  ["port"]=>
870  int(0)
871  ["path"]=>
872  string(1) "/"
873}
874
875--> http:///blah.com: bool(false)
876
877--> http://:80: bool(false)
878
879--> http://user@:80: bool(false)
880
881--> http://user:pass@:80: bool(false)
882
883--> http://:: bool(false)
884
885--> http://@/: bool(false)
886
887--> http://@:/: bool(false)
888
889--> http://:/: bool(false)
890
891--> http://?: bool(false)
892
893--> http://#: bool(false)
894
895--> http://?:: bool(false)
896
897--> http://:?: bool(false)
898
899--> http://blah.com:123456: bool(false)
900
901--> http://blah.com:abcdef: bool(false)
902Done
903