From 97e97c0b6f86079d57e6bdf1190fa0555a53eb20 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Sat, 24 Oct 2009 14:28:17 +0000 Subject: Support bracketted addresses. --- common/config-parser.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/common/config-parser.c b/common/config-parser.c index 881838f..a76e9c2 100644 --- a/common/config-parser.c +++ b/common/config-parser.c @@ -375,6 +375,7 @@ const char* cfg_parse_uri (char *uri, char** scheme, char** host, char **port, char** user, char** path, char** query) { + size_t len; char* t; *scheme = NULL; @@ -392,7 +393,7 @@ cfg_parse_uri (char *uri, char** scheme, char** host, char **port, *host = strsep(&uri, "/"); /* Parse the community out from the host */ - if(*host[0]) + if((*host)[0]) { t = strchr(*host, '@'); if(t) @@ -404,7 +405,7 @@ cfg_parse_uri (char *uri, char** scheme, char** host, char **port, } /* Parse out the port from the uri */ - if(*host[0]) + if((*host)[0]) { t = strrchr(*host, ':'); if(t && looks_like_port(t + 1)) @@ -414,6 +415,14 @@ cfg_parse_uri (char *uri, char** scheme, char** host, char **port, } } + /* Remove any brackets from the host */ + len = strlen (*host); + if(len > 2 && (*host)[0] == '[' && (*host)[len - 1] == ']') + { + (*host)[len - 1] = 0; + (*host)++; + } + if(!*host[0]) return "invalid uri: no host name found"; -- cgit v1.2.3