iliaa           Mon Oct 13 00:27:24 2003 EDT

  Modified files:              
    /php-src/ext/standard/tests/strings url_t.phpt 
    /php-src/ext/standard       url.c 
  Log:
  Fixed bug #25800 (parse_url() could not parse urls with empty port).
  
  
Index: php-src/ext/standard/tests/strings/url_t.phpt
diff -u php-src/ext/standard/tests/strings/url_t.phpt:1.5 
php-src/ext/standard/tests/strings/url_t.phpt:1.6
--- php-src/ext/standard/tests/strings/url_t.phpt:1.5   Mon Dec 30 11:42:49 2002
+++ php-src/ext/standard/tests/strings/url_t.phpt       Mon Oct 13 00:27:23 2003
@@ -64,7 +64,11 @@
 'mailto:[EMAIL PROTECTED]',
 '/foo.php?a=b&c=d',
 'foo.php?a=b&c=d',
-'http://user:[EMAIL PROTECTED]:8080?bar=1&boom=0'
+'http://user:[EMAIL PROTECTED]:8080?bar=1&boom=0',
+'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) {
@@ -615,4 +619,34 @@
   string(6) "passwd"
   ["query"]=>
   string(12) "bar=1&boom=0"
+}
+array(2) {
+  ["scheme"]=>
+  string(4) "file"
+  ["path"]=>
+  string(13) "/path/to/file"
+}
+array(3) {
+  ["scheme"]=>
+  string(4) "file"
+  ["host"]=>
+  string(4) "path"
+  ["path"]=>
+  string(8) "/to/file"
+}
+array(2) {
+  ["scheme"]=>
+  string(4) "file"
+  ["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: php-src/ext/standard/url.c
diff -u php-src/ext/standard/url.c:1.68 php-src/ext/standard/url.c:1.69
--- php-src/ext/standard/url.c:1.68     Mon Aug 11 19:16:53 2003
+++ php-src/ext/standard/url.c  Mon Oct 13 00:27:23 2003
@@ -15,7 +15,7 @@
    | Author: Jim Winstead <[EMAIL PROTECTED]>                                  |
    +----------------------------------------------------------------------+
  */
-/* $Id: url.c,v 1.68 2003/08/11 23:16:53 iliaa Exp $ */
+/* $Id: url.c,v 1.69 2003/10/13 04:27:23 iliaa Exp $ */
 
 #include <stdlib.h>
 #include <string.h>
@@ -197,17 +197,17 @@
        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 {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to