aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgrunfink <grunfink@comam.es>2026-04-05 10:34:49 +0200
committergrunfink <grunfink@comam.es>2026-04-05 10:34:49 +0200
commitfb52266b1c0104030ab36b7eacaa44e50c898fa9 (patch)
tree20bffd1421f7927c571fa5ca8bd865502329675b
parent29633a377fb6bfa34add754f23c25b4060ae678a (diff)
Strip HTML from a summary field.
Also, crop it to a reasonable length.
-rw-r--r--html.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/html.c b/html.c
index 51d64ed..a261ae4 100644
--- a/html.c
+++ b/html.c
@@ -2551,10 +2551,19 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
cw = "";
}
+ /* summary can't contain HTML */
+ xs *s1 = xs_regex_replace(v, "<[^>]+>", "");
+
+ /* crop stupidly long summaries */
+ if (xs_utf8_len(s1) > 1024) {
+ s1 = xs_utf8_crop_i(s1, 0, 1024);
+ s1 = xs_str_cat(s1, "...");
+ }
+
snac_content = xs_html_tag("details",
xs_html_attr(cw, NULL),
xs_html_tag("summary",
- xs_html_text(v),
+ xs_html_text(s1),
xs_html_text(L(" [SENSITIVE CONTENT]"))));
}
else