pidgin.2.x.y: 3f0fa1ca: UTF-8 salvage unknown strings in IRC

elb at pidgin.im elb at pidgin.im
Fri Sep 30 14:26:03 EDT 2011


----------------------------------------------------------------------
Revision: 3f0fa1ca9cfec741a0ca57563011468898c43064
Parent:   7eb1f6d56cc58bbb5b56b7df53955d36b9b419b8
Author:   elb at pidgin.im
Date:     09/30/11 14:23:57
Branch:   im.pidgin.pidgin.2.x.y
URL: http://d.pidgin.im/viewmtn/revision/info/3f0fa1ca9cfec741a0ca57563011468898c43064

Changelog: 

UTF-8 salvage unknown strings in IRC

Changes against parent 7eb1f6d56cc58bbb5b56b7df53955d36b9b419b8

  patched  libpurple/protocols/irc/parse.c

-------------- next part --------------
============================================================
--- libpurple/protocols/irc/parse.c	2a9a5d6a67100220c2f4186e69e281f55a1f3f18
+++ libpurple/protocols/irc/parse.c	42517267d9ee9cffb32fb9294d146f68c775832c
@@ -708,7 +708,14 @@ void irc_parse_msg(struct irc_conn *irc,
 		switch (fmt[i]) {
 		case 'v':
 			if (!(end = strchr(cur, ' '))) end = cur + strlen(cur);
-			args[i] = g_strndup(cur, end - cur);
+			/* This is a string of unknown encoding which we do not
+			 * want to transcode, but it may or may not be valid
+			 * UTF-8, so we'll salvage it.  If a nick/channel/target
+			 * field has inadvertently been marked verbatim, this
+			 * could cause weirdness. */
+			tmp = g_strndup(cur, end - cur);
+			args[i] = purple_utf8_salvage(tmp);
+			g_free(tmp);
 			cur += end - cur;
 			break;
 		case 't':
@@ -726,7 +733,9 @@ void irc_parse_msg(struct irc_conn *irc,
 			cur = cur + strlen(cur);
 			break;
 		case '*':
-			args[i] = g_strdup(cur);
+			/* Ditto 'v' above; we're going to salvage this in case
+			 * it leaks past the IRC prpl */
+			args[i] = purple_utf8_salvage(cur);
 			cur = cur + strlen(cur);
 			break;
 		default:


More information about the Commits mailing list