degesch: fix literal IPv6 server addresses

This commit is contained in:
Přemysl Eric Janouch 2015-07-19 23:30:28 +02:00
parent b947a2e4bc
commit 553f06d3ec
1 changed files with 6 additions and 1 deletions

View File

@ -4385,7 +4385,7 @@ irc_on_connector_connected (void *user_data, int socket)
static void static void
irc_split_host_port (char *s, char **host, char **port) irc_split_host_port (char *s, char **host, char **port)
{ {
char *colon = strchr (s, ':'); char *colon = strrchr (s, ':');
if (colon) if (colon)
{ {
*colon = '\0'; *colon = '\0';
@ -4394,6 +4394,11 @@ irc_split_host_port (char *s, char **host, char **port)
else else
*port = "6667"; *port = "6667";
// Unwrap IPv6 addresses in format_host_port_pair() format
size_t host_end = strlen (s) - 1;
if (*s == '[' && s[host_end] == ']')
s++[host_end] = '\0';
*host = s; *host = s;
} }