6399ca3
diff --git a/src/LYUtils.c b/src/LYUtils.c
6399ca3
index dd0a3dc..62a0591 100644
6399ca3
--- a/src/LYUtils.c
6399ca3
+++ b/src/LYUtils.c
6399ca3
@@ -2283,9 +2283,10 @@ UrlTypes is_url(char *filename)
6399ca3
 	return (result);
6399ca3
 
6399ca3
     /*
6399ca3
-     * Can't be a URL if it lacks a colon.
6399ca3
+     * Can't be a URL if it lacks a colon and if it starts with '[' it's
6399ca3
+     * probably IPv6 adress.
6399ca3
      */
6399ca3
-    if (NULL == strchr(cp, ':'))
6399ca3
+    if (NULL == strchr(cp, ':') || cp[0] == '[')
6399ca3
 	return (result);
6399ca3
 
6399ca3
     /*
6399ca3
@@ -4549,6 +4550,8 @@ BOOLEAN LYExpandHostForURL(char **AllocatedString,
6399ca3
 #ifdef INET6
6399ca3
     struct addrinfo hints, *res;
6399ca3
     int error;
6399ca3
+    char *begin;
6399ca3
+    char *end = NULL;
6399ca3
 #endif /* INET6 */
6399ca3
 
6399ca3
     /*
6399ca3
@@ -4593,7 +4596,7 @@ BOOLEAN LYExpandHostForURL(char **AllocatedString,
6399ca3
      * field after filling in the host field.  - FM
6399ca3
      */
6399ca3
     if ((StrColon = strrchr(Str, ':')) != NULL &&
6399ca3
-	isdigit(UCH(StrColon[1]))) {
6399ca3
+	isdigit(UCH(StrColon[1])) && strchr(StrColon, ']') == NULL) {
6399ca3
 	if (StrColon == Str) {
6399ca3
 	    goto cleanup;
6399ca3
 	}
6399ca3
@@ -4614,10 +4617,20 @@ BOOLEAN LYExpandHostForURL(char **AllocatedString,
6399ca3
 	fprintf(stdout, "%s '%s'%s\r\n", WWW_FIND_MESSAGE, host, FIRST_SEGMENT);
6399ca3
     }
6399ca3
 #ifdef INET6
6399ca3
+    begin = host;
6399ca3
+    if (host[0] == '[' && ((end = strrchr(host, ']')))) {
6399ca3
+	/*
6399ca3
+	 * cut '[' and ']' from the IPv6 address, e.g. [::1]
6399ca3
+	 */
6399ca3
+	begin = host + 1;
6399ca3
+	*end = '\0';
6399ca3
+    }
6399ca3
     memset(&hints, 0, sizeof(hints));
6399ca3
     hints.ai_family = PF_UNSPEC;
6399ca3
     hints.ai_socktype = SOCK_STREAM;
6399ca3
-    error = getaddrinfo(host, "80", &hints, &res;;
6399ca3
+    error = getaddrinfo(begin, "80", &hints, &res;;
6399ca3
+    if (end)
6399ca3
+	*end = ']';
6399ca3
 
6399ca3
     if (!error && res)
6399ca3
 #else