From 7c078db879c2f645a803224c5f9b70ed9cb8d911 Mon Sep 17 00:00:00 2001 From: Patrick Griffis Date: Fri, 11 Mar 2016 02:15:42 -0500 Subject: 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 --- src/common/outbound.c | 7 +++---- src/common/server.c | 3 ++- src/common/servlist.c | 13 ++++++++++++- 3 files changed, 17 insertions(+), 6 deletions(-) (limited to 'src/common') diff --git a/src/common/outbound.c b/src/common/outbound.c index a4611927..5ca8b783 100644 --- a/src/common/outbound.c +++ b/src/common/outbound.c @@ -3439,10 +3439,9 @@ cmd_server (struct session *sess, char *tbuf, char *word[], char *word_eol[]) } /* try to associate this connection with a listed network */ - if (!serv->network) - /* search for this hostname in the entire server list */ - serv->network = servlist_net_find_from_server (server_name); - /* may return NULL, but that's OK */ + /* may return NULL, but that's OK */ + if ((serv->network = servlist_net_find_from_server (server_name))) + server_set_encoding (serv, ((ircnet*)serv->network)->encoding); return TRUE; } diff --git a/src/common/server.c b/src/common/server.c index 709bfb22..b94f57e7 100644 --- a/src/common/server.c +++ b/src/common/server.c @@ -1728,7 +1728,8 @@ server_set_defaults (server *serv) serv->nick_modes = g_strdup ("ohv"); serv->sasl_mech = MECH_PLAIN; - server_set_encoding (serv, "UTF-8"); + if (!serv->encoding) + server_set_encoding (serv, "UTF-8"); serv->nickcount = 1; serv->end_of_motd = FALSE; 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; } -- cgit 1.4.1