commit ecff889

default  ·  2022-11-20 05:16:45 +0000 UTC
parent 3d66541
More RSS tweaks.
1 files changed,  +5, -14
M html.c
M html.c
+5, -14
 1@@ -1129,8 +1129,8 @@ 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-            xs *title   = xs_dup(content);
 6-            int i = -1;
 7+            xs *title   = xs_str_new(NULL);
 8+            int i;
 9 
10             /* add the post link */
11             xs *l = xs_fmt("<p><a href=\"%s\">%s</a><p>", id, id);
12@@ -1140,21 +1140,12 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char *
13             content = xs_replace_i(content, "<", "&lt;");
14             content = xs_replace_i(content, ">", "&gt;");
15 
16-            if (strlen(title) > 40)
17-                title = xs_crop(title, 0, i = 40);
18-
19-            if ((v = strchr(title, '<')))
20-                title = xs_crop(title, 0, i = (v - title));
21-
22-            if ((v = strchr(title, '&')))
23-                title = xs_crop(title, 0, i = (v - title));
24-
25-            if (i != -1)
26-                title = xs_str_cat(xs_strip(title), "...");
27+            for (i = 0; content[i] && content[i] != '<' && content[i] != '&' && i < 40; i++)
28+                title = xs_append_m(title, &content[i], 1);
29 
30             xs *s = xs_fmt(
31                 "<item>\n"
32-                "<title>%s</title>\n"
33+                "<title>%s...</title>\n"
34                 "<link>%s</link>\n"
35                 "<description>%s</description>\n"
36                 "</item>\n",