guint i;
gboolean space_seen = FALSE;
gsize len;
+ guint break_dist = 0; /* distance since last break point */
len = strlen (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;
case '&' : g_string_append (html, "&"); break;
case '"' : g_string_append (html, """); break;
case '\'' : g_string_append (html, "'"); break;
- case '\n' : g_string_append (html, "<br>\n"); break;
- case '\t' : g_string_append (html, " "); break; /* note the space at the end*/
+ case '\n' : g_string_append (html, "<br>\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;