diff libpurple/protocols/msn/msg.c @ 24728:c09a647fd538

When parsing MSN message payload headers, check for folded lines. The only important one right now is the boundary="..." part of the Content-Type for multi-part messages.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sun, 14 Dec 2008 23:14:34 +0000
parents 7e8175f9b009
children b0e069922896
line wrap: on
line diff
--- a/libpurple/protocols/msn/msg.c	Sun Dec 14 23:11:27 2008 +0000
+++ b/libpurple/protocols/msn/msg.c	Sun Dec 14 23:14:34 2008 +0000
@@ -231,6 +231,25 @@
 	{
 		const char *key, *value;
 
+		/* If this line starts with whitespace, it's been folded from the
+		   previous line and won't have ':'. */
+		if ((**cur == ' ') || (**cur == '\t')) {
+			tokens = g_strsplit(g_strchug(*cur), "=\"", 2);
+			key = tokens[0];
+			value = tokens[1];
+
+			/* The only one I care about is 'boundary' (which is folded from
+			   the key 'Content-Type'), so only process that. */
+			if (!strcmp(key, "boundary")) {
+				char *end = strchr(value, '\"');
+				*end = '\0';
+				msn_message_set_attr(msg, key, value);
+			}
+
+			g_strfreev(tokens);
+			continue;
+		}
+
 		tokens = g_strsplit(*cur, ": ", 2);
 
 		key = tokens[0];