changeset 17293:77b15be2179f

Convert newlines to ' ' when receiving XHTML from Jabber
author Sean Egan <seanegan@gmail.com>
date Thu, 24 May 2007 23:14:06 +0000
parents a7c07b57f3e4
children 1c62deca5958
files libpurple/protocols/jabber/message.c
diffstat 1 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/message.c	Thu May 24 22:39:22 2007 +0000
+++ b/libpurple/protocols/jabber/message.c	Thu May 24 23:14:06 2007 +0000
@@ -324,8 +324,17 @@
 				g_free(msg);
 			}
 		} else if(!strcmp(child->name, "html")) {
-			if(!jm->xhtml && xmlnode_get_child(child, "body"))
+			if(!jm->xhtml && xmlnode_get_child(child, "body")) {
+				char *c;
 				jm->xhtml = xmlnode_to_str(child, NULL);
+			        /* Convert all newlines to whitespace. Technically, even regular, non-XML HTML is supposed to ignore newlines, but Pidgin has, as convention
+			 	 * treated \n as a newline for compatibility with other protocols
+				 */
+				for (c = jm->xhtml; *c != '\0'; c++) {
+					if (*c == '\n') 
+						*c = ' ';
+				}
+			}
 		} else if(!strcmp(child->name, "active")) {
 			jm->chat_state = JM_STATE_ACTIVE;
 			jm->typing_style |= JM_TS_JEP_0085;
@@ -535,6 +544,7 @@
 	char *buf;
 	char *xhtml;
 	char *resource;
+	char *c;
 
 	if(!who || !msg)
 		return 0;
@@ -569,7 +579,7 @@
 	}
 
 	buf = g_strdup_printf("<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'>%s</body></html>", msg);
-
+	
 	purple_markup_html_to_xhtml(buf, &xhtml, &jm->body);
 	g_free(buf);