Hi, On Tue, Oct 11, 2011 at 04:28:31PM +0200, Roland Rosenfeld wrote:
> mutt -fimap://user:pass@'[::1]' > mutt -fpop://user:pass@'[::1]' > > but with this I run into error messages and mutt terminates with the > following messages: > > imap://user:pass@[::1] is an invalid IMAP path > pop://user:pass@[::1] is an invalid POP path > > I also tried the same without brackets, but this also fails (as > expected, because isn't defined whether the last colon is part of the > IP or the separator of the port number). > > Maybe there is some other syntax expected, but I didn't find a hint in > the manual... I could not either, so I cooked a (dirty) patch for that. Attached. Not tagging patch, as I first want to have some review of it :) Regards Evgeni
# HG changeset patch # User evg...@golov.de # Date 1394440540 -3600 # Mon Mar 10 09:35:40 2014 +0100 # Node ID 66fa4d508db0efa22957f260ab6d7b5626f64b42 # Parent 1d8b2c1ec4f49e4d1773b9e7511396d0e27747c6 allow parsing of URIs with IPv6 literal addresses (RFCs 2732 and 3986) diff -r 1d8b2c1ec4f4 -r 66fa4d508db0 mutt_socket.c --- a/mutt_socket.c Sun Mar 09 20:53:51 2014 +0100 +++ b/mutt_socket.c Mon Mar 10 09:35:40 2014 +0100 @@ -442,6 +442,8 @@ int fd; char *host_idna = NULL; + char *host = NULL; + char *tmp = NULL; #ifdef HAVE_GETADDRINFO /* --- IPv4/6 --- */ @@ -474,10 +476,18 @@ host_idna = conn->account.host; # endif + if ((host = strchr(host_idna, '[')) && (tmp = strrchr(host_idna, ']'))) + { + *tmp = '\0'; + host = strchr(host_idna, '[')+1; + } + else + host = host_idna; + if (!option(OPTNOCURSES)) mutt_message (_("Looking up %s..."), conn->account.host); - rc = getaddrinfo (host_idna, port, &hints, &res); + rc = getaddrinfo (host, port, &hints, &res); # ifdef HAVE_LIBIDN FREE (&host_idna); diff -r 1d8b2c1ec4f4 -r 66fa4d508db0 url.c --- a/url.c Sun Mar 09 20:53:51 2014 +0100 +++ b/url.c Mon Mar 10 09:35:40 2014 +0100 @@ -111,7 +111,7 @@ * means no port given. */ static int ciss_parse_userhost (ciss_url_t *ciss, char *src) { - char *t, *p; + char *t, *p, *v; ciss->user = NULL; ciss->pass = NULL; @@ -147,7 +147,17 @@ else t = src; - if ((p = strchr (t, ':'))) + if ((v = strchr (t, '['))) + { + if (!(v = strrchr (v, ']'))) + { + v = t; + } + } + else + v = t; + + if ((p = strchr (v, ':'))) { int t; *p++ = '\0';