commit 86aa0ff
default
·
2022-11-20 04:24:11 +0000 UTC
parent 50d73a6
More RSS tweaks.
1 files changed,
+15,
-2
M
html.c
M
html.c
+15,
-2
1@@ -1129,19 +1129,32 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char *
2 continue;
3
4 xs *content = sanitize(xs_dict_get(msg, "content"));
5- char *title = xs_dict_get(msg, "published");
6+ xs *title = xs_dup(content);
7+ int i = -1;
8
9 /* escape tags */
10 content = xs_replace_i(content, "<", "<");
11 content = xs_replace_i(content, ">", ">");
12
13+ if (strlen(title) > 40)
14+ title[i = 40] = '\0';
15+
16+ if ((v = strchr(title, '<')))
17+ title[i = (v - title)] = '\0';
18+
19+ if ((v = strchr(title, '&')))
20+ title[i = (v - title)] = '\0';
21+
22+ if (i != -1)
23+ title = xs_str_cat(xs_strip(title), "...");
24+
25 xs *s = xs_fmt(
26 "<item>\n"
27 "<title>%s</title>\n"
28 "<link>%s</link>\n"
29 "<description>%s</description>\n"
30 "</item>\n",
31- xs_is_null(title) ? "..." : title, id, content
32+ title, id, content
33 );
34
35 rss = xs_str_cat(rss, s);