diff options
author | Stig Venaas <venaas@php.net> | 2000-09-22 00:12:00 +0000 |
---|---|---|
committer | Stig Venaas <venaas@php.net> | 2000-09-22 00:12:00 +0000 |
commit | 0776f7d3d734c382b74ca399529a215d2afa0f0e (patch) | |
tree | 129b53979a40762ab40918f15de905c83ed08dd7 /ext/standard/url.c | |
parent | d9b4f90969f78a11240fd632a7199e5c2c8a6300 (diff) | |
download | php-git-0776f7d3d734c382b74ca399529a215d2afa0f0e.tar.gz |
Parsing of URLs with literal IPv6 addresses, see RFC 2732
@- IPv6 support in fopen (one can access IPv6 ftp/web servers) (Stig Venaas)
Diffstat (limited to 'ext/standard/url.c')
-rw-r--r-- | ext/standard/url.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/ext/standard/url.c b/ext/standard/url.c index ab12801d30..004956081c 100644 --- a/ext/standard/url.c +++ b/ext/standard/url.c @@ -116,8 +116,8 @@ php_url *url_parse(char *str) regfree(&re); /* free the old regex */ - if ((cerr=regcomp(&re, "^(([^@:]+)(:([^@:]+))?@)?([^:@]+)(:([^:@]+))?", REG_EXTENDED)) - || (err=regexec(&re, result, 10, subs, 0))) { + if ((cerr=regcomp(&re, "^(([^@:]+)(:([^@:]+))?@)?((\\[(.*)\\])|([^:@]+))(:([^:@]+))?", REG_EXTENDED)) + || (err=regexec(&re, result, 11, subs, 0))) { STR_FREE(ret->scheme); STR_FREE(ret->path); STR_FREE(ret->query); @@ -135,11 +135,13 @@ php_url *url_parse(char *str) if (subs[4].rm_so != -1 && subs[4].rm_so < length) { ret->pass = estrndup(result + subs[4].rm_so, subs[4].rm_eo - subs[4].rm_so); } - if (subs[5].rm_so != -1 && subs[5].rm_so < length) { - ret->host = estrndup(result + subs[5].rm_so, subs[5].rm_eo - subs[5].rm_so); - } if (subs[7].rm_so != -1 && subs[7].rm_so < length) { - ret->port = (unsigned short) strtol(result + subs[7].rm_so, NULL, 10); + ret->host = estrndup(result + subs[7].rm_so, subs[7].rm_eo - subs[7].rm_so); + } else if (subs[8].rm_so != -1 && subs[8].rm_so < length) { + ret->host = estrndup(result + subs[8].rm_so, subs[8].rm_eo - subs[8].rm_so); + } + if (subs[10].rm_so != -1 && subs[10].rm_so < length) { + ret->port = (unsigned short) strtol(result + subs[10].rm_so, NULL, 10); } efree(result); } |