e5e7b7
From 943ec853fab1432e0f05d4f1b8fd4605765b5692 Mon Sep 17 00:00:00 2001
e5e7b7
From: Kernc <kerncece@gmail.com>
e5e7b7
Date: Thu, 22 Sep 2016 01:24:53 +0200
e5e7b7
Subject: [PATCH] IRC: Skip EXTERNAL SASL auth mechanism
e5e7b7
e5e7b7
Makes Freenode and other servers that prefer SASL EXTERNAL
e5e7b7
fingerprint authentication work again.
e5e7b7
e5e7b7
Ref:
e5e7b7
  "Cannot connect to IRC (Freenode)"
e5e7b7
  https://pidgin.im/pipermail/support/2016-September/029627.html
e5e7b7
e5e7b7
--HG--
e5e7b7
branch : release-2.x.y
e5e7b7
extra : source : 610656636af6d1d6fdd6723d5ef311c903b6a804
e5e7b7
---
e5e7b7
 libpurple/protocols/irc/msgs.c | 11 +++++++++++
e5e7b7
 1 file changed, 11 insertions(+)
e5e7b7
e5e7b7
diff --git a/libpurple/protocols/irc/msgs.c b/libpurple/protocols/irc/msgs.c
e5e7b7
index c44ff387686e..99baf4ca2e18 100644
e5e7b7
--- a/libpurple/protocols/irc/msgs.c
e5e7b7
+++ b/libpurple/protocols/irc/msgs.c
e5e7b7
@@ -1574,6 +1574,8 @@ irc_msg_cap(struct irc_conn *irc, const char *name, const char *from, char **arg
e5e7b7
 	int id = 0;
e5e7b7
 	PurpleConnection *gc = purple_account_get_connection(irc->account);
e5e7b7
 	const char *mech_list = NULL;
e5e7b7
+	char *pos;
e5e7b7
+	size_t index;
e5e7b7
 
e5e7b7
 	if (strncmp(args[2], "sasl ", 6))
e5e7b7
 		return;
e5e7b7
@@ -1637,6 +1639,15 @@ irc_msg_cap(struct irc_conn *irc, const char *name, const char *from, char **arg
e5e7b7
 	}
e5e7b7
 
e5e7b7
 	irc->sasl_mechs = g_string_new(mech_list);
e5e7b7
+	/* Drop EXTERNAL mechanism since we don't support it */
e5e7b7
+	if ((pos = strstr(irc->sasl_mechs->str, "EXTERNAL"))) {
e5e7b7
+		index = pos - irc->sasl_mechs->str;
e5e7b7
+		g_string_erase(irc->sasl_mechs, index, strlen("EXTERNAL"));
e5e7b7
+		/* Remove space which separated this mech from the next */
e5e7b7
+		if ((irc->sasl_mechs->str)[index] == ' ') {
e5e7b7
+			g_string_erase(irc->sasl_mechs, index, 1);
e5e7b7
+		}
e5e7b7
+	}
e5e7b7
 
e5e7b7
 	irc_auth_start_cyrus(irc);
e5e7b7
 }
e5e7b7
-- 
e5e7b7
2.14.4
e5e7b7