From: Ilia Alshanetsky Date: Thu, 28 Sep 2006 15:16:40 +0000 (+0000) Subject: MFH: Fixed bug #38859 (parse_url() fails if passing '@' in passwd). X-Git-Tag: php-4.4.5RC1~62 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=161c8ed86b2a2d99525698a8a360889f97f998f5;p=php MFH: Fixed bug #38859 (parse_url() fails if passing '@' in passwd). --- diff --git a/NEWS b/NEWS index 1559b2037f..f4c2b98e35 100644 --- 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 diff --git a/ext/standard/tests/strings/url_t.phpt b/ext/standard/tests/strings/url_t.phpt index 86605ace27..612f773195 100644 --- a/ext/standard/tests/strings/url_t.phpt +++ b/ext/standard/tests/strings/url_t.phpt @@ -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 diff --git a/ext/standard/url.c b/ext/standard/url.c index d15186893b..daf61cc383 100644 --- a/ext/standard/url.c +++ b/ext/standard/url.c @@ -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));