]> granicus.if.org Git - php/commitdiff
MFH: Fixed bug #32813 (parse_url() does not handle scheme-only urls properly).
authorIlia Alshanetsky <iliaa@php.net>
Mon, 25 Apr 2005 23:48:31 +0000 (23:48 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 25 Apr 2005 23:48:31 +0000 (23:48 +0000)
NEWS
ext/standard/tests/strings/url_t.phpt
ext/standard/url.c

diff --git a/NEWS b/NEWS
index f50d1068d4528d48d62afad39116e422fdcf3294..43f40393f338f1901ec2347c375db1681cfa5829 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ PHP                                                                        NEWS
 - Changed sha1_file() and md5_file() functions to use streams instead of
   low level IO. (Uwe)
 - Fixed memory corruption in ImageTTFText() with 64bit systems. (Andrey)
+- Fixed bug #32813 (parse_url() does not handle scheme-only urls properly). (Ilia)
 - Fixed bug #32809 (Missing T1LIB support on Windows). (Edin)
 - Fixed bug #32802 (General cookie overrides more specific cookie). (Ilia)
 - Fixed bug #32776 (SOAP doesn't support one-way operations). (Dmitry)
index dd323ffc235ca67b4f1ed59e7a89685bc56d41d7..1e4dd3566df84bbd7089761a731df9efde86020a 100644 (file)
@@ -67,7 +67,8 @@ $sample_urls = array (
 'file://path/to/file',
 'file:/path/to/file',
 'http://1.2.3.4:/abc.asp?a=1&b=2',
-'http://foo.com#bar'
+'http://foo.com#bar',
+'scheme:'
 );
 
     foreach ($sample_urls as $url) {
@@ -657,3 +658,7 @@ array(3) {
   ["fragment"]=>
   string(3) "bar"
 }
+array(1) {
+  ["scheme"]=>
+  string(6) "scheme"
+}
index 1c2091f9fe08d7e6d519ed4a7a4ccd5b30c20c67..63c5f60dd516be578ba44ab23451d8a44b3fd0e9 100644 (file)
@@ -104,6 +104,12 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length)
 
        /* parse scheme */
        if ((e = memchr(s, ':', length)) && (e - s)) {
+               if (*(e + 1) == '\0') { /* only scheme is available */
+                       ret->scheme = estrndup(s, (e - s));
+                       php_replace_controlchars_ex(ret->scheme, (e - s));
+                       goto end;
+               }
+
                /* 
                 * certain schemas like mailto: and zlib: may not have any / after them
                 * this check ensures we support those.
@@ -303,7 +309,7 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length)
                ret->path = estrndup(s, (ue-s));
                php_replace_controlchars_ex(ret->path, (ue - s));
        }
-
+end:
        return ret;
 }
 /* }}} */