From 88d920258393a680c06e5dc5663f466ab359df6c Mon Sep 17 00:00:00 2001 From: Stefan Becker Date: Sat, 5 Mar 2011 00:46:17 +0200 Subject: [PATCH] Fix #3198585: Extra line breaks At least for some users the M$ OC client inserts line breaks (\r\n) into HTML messages. Pidgin unfortunately does not consider \r and \n in HTML as white space, but renders them as line breaks. So the pidgin-sipe user sees extra line breaks. If the content type is text/html then we now strip out \r and \n from the text. --- src/core/sipmsg.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/core/sipmsg.c b/src/core/sipmsg.c index 44972a17..5c386405 100644 --- a/src/core/sipmsg.c +++ b/src/core/sipmsg.c @@ -615,7 +615,23 @@ gchar *get_html_message(const gchar *ms_text_format_in, const gchar *body_in) } } - if (!g_str_has_prefix(ms_text_format, "text/html")) { // NOT html + if (g_str_has_prefix(ms_text_format, "text/html")) { + /* + * HTML uses tags for formatting, not line breaks. But + * clients still might render them, so we need to remove + * them to avoid incorrect text rendering. + */ + gchar *d = res; + const gchar *s = res; + gchar c; + + /* No ANSI C nor glib function seems to exist for this :-( */ + while ((c = *s++)) + if ((c != '\n') && (c != '\r')) + *d++ = c; + *d = c; + + } else { char *tmp = res; res = g_markup_escape_text(res, -1); // as this is not html g_free(tmp); -- 2.11.4.GIT