commit fb52266
grunfink
·
2026-04-05 08:34:49 +0000 UTC
parent 29633a3
Strip HTML from a summary field. Also, crop it to a reasonable length.
1 files changed,
+10,
-1
M
html.c
M
html.c
+10,
-1
1@@ -2551,10 +2551,19 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
2 cw = "";
3 }
4
5+ /* summary can't contain HTML */
6+ xs *s1 = xs_regex_replace(v, "<[^>]+>", "");
7+
8+ /* crop stupidly long summaries */
9+ if (xs_utf8_len(s1) > 1024) {
10+ s1 = xs_utf8_crop_i(s1, 0, 1024);
11+ s1 = xs_str_cat(s1, "...");
12+ }
13+
14 snac_content = xs_html_tag("details",
15 xs_html_attr(cw, NULL),
16 xs_html_tag("summary",
17- xs_html_text(v),
18+ xs_html_text(s1),
19 xs_html_text(L(" [SENSITIVE CONTENT]"))));
20 }
21 else