]> granicus.if.org Git - php/commitdiff
MFH: Fixed bug #25800 (parse_url() could not parse urls with empty port).
authorIlia Alshanetsky <iliaa@php.net>
Mon, 13 Oct 2003 04:28:34 +0000 (04:28 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 13 Oct 2003 04:28:34 +0000 (04:28 +0000)
NEWS
ext/standard/tests/strings/url_t.phpt
ext/standard/url.c

diff --git a/NEWS b/NEWS
index 532d53e87b3d551a46ba5ccdd9f2815a1cdde117..aab8bbbc6e4aad8c12ec493b75c9616e574047c8 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ PHP 4                                                                      NEWS
   POSIX compatible mode. (K.Kosako <kosako at sofnec.co.jp>, Moriyoshi)
 - Fixed bug #25814 (Make flock() return correct value when 3rd argument is
   used). (Ilia)
+- Fixed bug #25800 (parse_url() could not parse urls with empty port). (Ilia)
 - Fixed bug #25780 (ext/session: invalid "session.cookie_lifetime" makes 
   session_start() to crash in win32). (Jani)
 - Fixed bug #25770 (Segfault with PHP and bison 1.875). (eggert@gnu.org, Marcus)
index f3bd83819c70e59e6204a880a253b3931b3957a3..1af113a69505420465340bfc7c045986b56e6bfe 100644 (file)
@@ -67,7 +67,8 @@ $sample_urls = array (
 'http://user:passwd@www.example.com:8080?bar=1&boom=0',
 'file:///path/to/file',
 'file://path/to/file',
-'file:/path/to/file'
+'file:/path/to/file',
+'http://1.2.3.4:/abc.asp?a=1&b=2'
 );
 
     foreach ($sample_urls as $url) {
@@ -639,3 +640,13 @@ array(2) {
   ["path"]=>
   string(13) "/path/to/file"
 }
+array(4) {
+  ["scheme"]=>
+  string(4) "http"
+  ["host"]=>
+  string(7) "1.2.3.4"
+  ["path"]=>
+  string(8) "/abc.asp"
+  ["query"]=>
+  string(7) "a=1&b=2"
+}
index 3490981038f789fc1f198fd75591753e84bcec74..24967ce127ad4e2ae4729aa5859ff8f9b3e1690b 100644 (file)
@@ -197,17 +197,17 @@ PHPAPI php_url *php_url_parse(char *str)
        if ((p = memchr(s, ':', (e-s)))) {
                if (!ret->port) {
                        p++;
-                       if ( e-p > 5 || e-p < 1 ) { /* port cannot be longer then 5 characters */
+                       if (e-p > 5) { /* port cannot be longer then 5 characters */
                                STR_FREE(ret->scheme);
                                STR_FREE(ret->user);
                                STR_FREE(ret->pass);
                                efree(ret);
                                return NULL;
+                       } else if (e - p > 0) {
+                               memcpy(port_buf, p, (e-p));
+                               port_buf[e-p] = '\0';
+                               ret->port = atoi(port_buf);
                        }
-               
-                       memcpy(port_buf, p, (e-p));
-                       port_buf[e-p] = '\0';
-                       ret->port = atoi(port_buf);
                        p--;
                }       
        } else {