diff options
author | Sara Golemon <pollita@php.net> | 2004-04-27 19:13:13 +0000 |
---|---|---|
committer | Sara Golemon <pollita@php.net> | 2004-04-27 19:13:13 +0000 |
commit | 99b6724a4c22e5a94ef3e7c49b8c4254c80f3774 (patch) | |
tree | 9609eb082436b8a0a57a3050fbedaa8d385976e1 /ext/standard/url.c | |
parent | e44c06c14efb91b1dc56841f7791a2a6dff56986 (diff) | |
download | php-git-99b6724a4c22e5a94ef3e7c49b8c4254c80f3774.tar.gz |
BugFix 28187 parse_url does not handle scheme://[0123:4567::89]:12345/etc style IPv6 embedded address URLs
Diffstat (limited to 'ext/standard/url.c')
-rw-r--r-- | ext/standard/url.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/ext/standard/url.c b/ext/standard/url.c index 76bbc5c43d..69dd45d7d9 100644 --- a/ext/standard/url.c +++ b/ext/standard/url.c @@ -198,13 +198,20 @@ PHPAPI php_url *php_url_parse(char const *str) s = p + 1; } - + /* check for port */ - /* memrchr is a GNU specific extension - Emulate for wide compatability */ - for(p = e; *p != ':' && p >= s; p--); + if (*s == '[' && *(e-1) == ']') { + /* Short circuit portscan, + we're dealing with an + IPv6 embedded address */ + p = s; + } else { + /* memrchr is a GNU specific extension + Emulate for wide compatability */ + for(p = e; *p != ':' && p >= s; p--); + } - if (*p == ':') { + if (p >= s && *p == ':') { if (!ret->port) { p++; if (e-p > 5) { /* port cannot be longer then 5 characters */ @@ -224,6 +231,11 @@ PHPAPI php_url *php_url_parse(char const *str) p = e; } + if (*s == '[' && *(p-1) == ']') { + s++; + p--; + } + /* check if we have a valid host, if we don't reject the string as url */ if ((p-s) < 1) { STR_FREE(ret->scheme); |