summary refs log tree commit diff stats
path: root/src/common/servlist.c
diff options
context:
space:
mode:
authorPatrick Griffis <tingping@tingping.se>2016-03-11 02:15:42 -0500
committerPatrick Griffis <tingping@tingping.se>2016-03-11 02:15:42 -0500
commit7c078db879c2f645a803224c5f9b70ed9cb8d911 (patch)
treebfd9f88a569238e5cc4ad7eddb0094b10b99226d /src/common/servlist.c
parentebb0fd6905d6af6daaa2db15b71d4cacd028e14a (diff)
Fix loading encoding from network list on connect
- Fix setting new encoding when switching networks
- Ignore ports when looking for network by hostname
- Only set UTF-8 when nothing explicitly set

Fixes #1628
Diffstat (limited to 'src/common/servlist.c')
-rw-r--r--src/common/servlist.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/common/servlist.c b/src/common/servlist.c
index f043d4bc..897f0d0f 100644
--- a/src/common/servlist.c
+++ b/src/common/servlist.c
@@ -714,8 +714,19 @@ servlist_net_find_from_server (char *server_name)
 		slist = net->servlist;
 		while (slist)
 		{
+			gsize hostname_len;
+			const char *hostname, *p;
+
 			serv = slist->data;
-			if (g_ascii_strcasecmp (serv->hostname, server_name) == 0)
+			hostname = serv->hostname;
+
+			/* Ignore port when comparing */
+			if ((p = strchr (hostname, '/')))
+				hostname_len = p - hostname;
+			else
+				hostname_len = strlen (hostname);
+
+			if (g_ascii_strncasecmp (hostname, server_name, hostname_len) == 0)
 				return net;
 			slist = slist->next;
 		}