X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fmodest-text-utils.c;h=3c32ada5bbda1c8adc75cdf0c1d0d1755e9ace58;hb=bfd933c3b43405833c3c8f794479c16b0c29f49f;hp=52d9ecf2221429a6f8a4a62bf8aafb56aa0f3d43;hpb=53dc7de1843cd26cd027d1f8653165f769c7e2ed;p=modest diff --git a/src/modest-text-utils.c b/src/modest-text-utils.c index 52d9ecf..3c32ada 100644 --- a/src/modest-text-utils.c +++ b/src/modest-text-utils.c @@ -300,6 +300,7 @@ modest_text_utils_convert_buffer_to_html (GString *html, const gchar *data) guint i; gboolean space_seen = FALSE; gsize len; + guint break_dist = 0; /* distance since last break point */ len = strlen (data); @@ -312,6 +313,15 @@ modest_text_utils_convert_buffer_to_html (GString *html, const gchar *data) space_seen = FALSE; } + /* we artificially insert a breakpoint (newline) + * after 256, to make sure our lines are not so long + * they will DOS the regexping later + */ + if (++break_dist == 256) { + g_string_append_c (html, '\n'); + break_dist = 0; + } + switch (kar) { case 0: break; /* ignore embedded \0s */ case '<' : g_string_append (html, "<"); break; @@ -319,9 +329,10 @@ modest_text_utils_convert_buffer_to_html (GString *html, const gchar *data) case '&' : g_string_append (html, "&"); break; case '"' : g_string_append (html, """); break; case '\'' : g_string_append (html, "'"); break; - case '\n' : g_string_append (html, "
\n"); break; - case '\t' : g_string_append (html, "    "); break; /* note the space at the end*/ + case '\n' : g_string_append (html, "
\n"); break_dist= 0; break; + case '\t' : g_string_append (html, "    "); break_dist=0; break; /* note the space at the end*/ case ' ': + break_dist = 0; if (space_seen) { /* second space in a row */ g_string_append (html, "  "); space_seen = FALSE;