From 86aa0ff4b6b0c7fe054e027be6492f07f9a3d7f2 Mon Sep 17 00:00:00 2001 From: default Date: Sun, 20 Nov 2022 05:24:11 +0100 Subject: More RSS tweaks. --- html.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/html.c b/html.c index dda7237..533bb44 100644 --- a/html.c +++ b/html.c @@ -1129,19 +1129,32 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char * continue; xs *content = sanitize(xs_dict_get(msg, "content")); - char *title = xs_dict_get(msg, "published"); + xs *title = xs_dup(content); + int i = -1; /* escape tags */ content = xs_replace_i(content, "<", "<"); content = xs_replace_i(content, ">", ">"); + if (strlen(title) > 40) + title[i = 40] = '\0'; + + if ((v = strchr(title, '<'))) + title[i = (v - title)] = '\0'; + + if ((v = strchr(title, '&'))) + title[i = (v - title)] = '\0'; + + if (i != -1) + title = xs_str_cat(xs_strip(title), "..."); + xs *s = xs_fmt( "\n" "%s\n" "%s\n" "%s\n" "\n", - xs_is_null(title) ? "..." : title, id, content + title, id, content ); rss = xs_str_cat(rss, s); -- cgit v1.2.3