]> granicus.if.org Git - php/commitdiff
MFH: Fixed bug #38859 (parse_url() fails if passing '@' in passwd).
authorIlia Alshanetsky <iliaa@php.net>
Thu, 28 Sep 2006 15:16:40 +0000 (15:16 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 28 Sep 2006 15:16:40 +0000 (15:16 +0000)
NEWS
ext/standard/tests/strings/url_t.phpt
ext/standard/url.c

diff --git a/NEWS b/NEWS
index 1559b2037f260082d631345c77c7d03a645c84d7..f4c2b98e3504066876a7cc7429138998952cabe9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ PHP 4                                                                      NEWS
 ?? ??? 2006, Version 4.4.5
 - Updated PCRE to version 6.7. (Ilia)
 - Fixed bug #38963 (Fixed a possible open_basedir bypass in tempnam()). (Ilia)
+- Fixed bug #38859 (parse_url() fails if passing '@' in passwd). (Tony,Ilia)
 - Fixed bug #38534 (segfault when calling setlocale() in userspace session
   handler). (Tony)
 - Fixed bug #38450 (constructor is not called for classes used in userspace
index 86605ace272ed2ac080ec2b6c8d867ea7c7fdee7..612f7731951559ffd70f7969b21cc989b95caadb 100644 (file)
@@ -72,6 +72,7 @@ $sample_urls = array (
 'http://foo.com#bar',
 'scheme:',
 'foo+bar://baz@bang/bla',
+'http://user:@pass@host/path?argument?value#etc',
 );
 
     foreach ($sample_urls as $url) {
@@ -521,11 +522,11 @@ array(7) {
   ["scheme"]=>
   string(4) "http"
   ["host"]=>
-  string(19) "hideout@www.php.net"
+  string(11) "www.php.net"
   ["port"]=>
   int(80)
   ["user"]=>
-  string(6) "secret"
+  string(14) "secret@hideout"
   ["path"]=>
   string(10) "/index.php"
   ["query"]=>
@@ -675,3 +676,19 @@ array(4) {
   ["path"]=>
   string(4) "/bla"
 }
+array(7) {
+  ["scheme"]=>
+  string(4) "http"
+  ["host"]=>
+  string(4) "host"
+  ["user"]=>
+  string(4) "user"
+  ["pass"]=>
+  string(5) "@pass"
+  ["path"]=>
+  string(5) "/path"
+  ["query"]=>
+  string(14) "argument?value"
+  ["fragment"]=>
+  string(3) "etc"
+}
\ No newline at end of file
index d15186893bd8ee1aa5407cd8420b3bb98bb8b400..daf61cc383c8f85440aa6ed89b1c7e6d78ce7e26 100644 (file)
@@ -202,9 +202,17 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length)
        } else {
                e = p;
        }       
+
+       {
+               char *t = s;
+               p = NULL;
+               while (e > t && (t = memchr(t, '@', (e-t)))) {
+                       p = t++;
+               }
+       }
                
        /* check for login and password */
-       if ((p = memchr(s, '@', (e-s)))) {
+       if (p) {
                if ((pp = memchr(s, ':', (p-s)))) {
                        if ((pp-s) > 0) {
                                ret->user = estrndup(s, (pp-s));