From 03c709802eebcacdabe2c2738e166da9f4cb1f31 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 8 Jun 2010 17:14:22 +0200 Subject: empathy_string_replace_escaped: remove '\r' (#620903) --- libempathy-gtk/empathy-string-parser.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-string-parser.c b/libempathy-gtk/empathy-string-parser.c index 5c3fb1972..52c726c69 100644 --- a/libempathy-gtk/empathy-string-parser.c +++ b/libempathy-gtk/empathy-string-parser.c @@ -185,9 +185,23 @@ empathy_string_replace_escaped (const gchar *text, { GString *string = user_data; gchar *escaped; + guint i; + gssize escaped_len, old_len; escaped = g_markup_escape_text (text, len); - g_string_append (string, escaped); + escaped_len = strlen (escaped); + + /* Allocate more space to string (we really need a g_string_extend...) */ + old_len = string->len; + g_string_set_size (string, old_len + escaped_len); + g_string_truncate (string, old_len); + + /* Remove '\r' */ + for (i = 0; i < escaped_len; i++) { + if (escaped[i] != '\r') + g_string_append_c (string, escaped[i]); + } + g_free (escaped); } -- cgit v1.2.3