diff --git a/src/cli_common.c b/src/cli_common.c index 0b13db5dc..421e7d34a 100644 --- a/src/cli_common.c +++ b/src/cli_common.c @@ -352,9 +352,19 @@ void parseRedisUri(const char *uri, const char* tool_name, cliConnInfo *connInfo path = strchr(curr, '/'); if (*curr != '/') { host = path ? path - 1 : end; - if ((port = strchr(curr, ':'))) { - connInfo->hostport = atoi(port + 1); - host = port - 1; + if (*curr == '[') { + curr += 1; + if ((port = strchr(curr, ']'))) { + if (*(port+1) == ':') { + connInfo->hostport = atoi(port + 2); + } + host = port - 1; + } + } else { + if ((port = strchr(curr, ':'))) { + connInfo->hostport = atoi(port + 1); + host = port - 1; + } } sdsfree(connInfo->hostip); connInfo->hostip = sdsnewlen(curr, host - curr + 1);