diff options
| author | 2022-11-20 05:24:11 +0100 | |
|---|---|---|
| committer | 2022-11-20 05:24:11 +0100 | |
| commit | 86aa0ff4b6b0c7fe054e027be6492f07f9a3d7f2 (patch) | |
| tree | dfd7980cb6b90c0e028be6798133528b6663ee05 /html.c | |
| parent | RSS improvements. (diff) | |
| download | snac2-86aa0ff4b6b0c7fe054e027be6492f07f9a3d7f2.tar.gz snac2-86aa0ff4b6b0c7fe054e027be6492f07f9a3d7f2.tar.xz snac2-86aa0ff4b6b0c7fe054e027be6492f07f9a3d7f2.zip | |
More RSS tweaks.
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 17 |
1 files changed, 15 insertions, 2 deletions
| @@ -1129,19 +1129,32 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char * | |||
| 1129 | continue; | 1129 | continue; |
| 1130 | 1130 | ||
| 1131 | xs *content = sanitize(xs_dict_get(msg, "content")); | 1131 | xs *content = sanitize(xs_dict_get(msg, "content")); |
| 1132 | char *title = xs_dict_get(msg, "published"); | 1132 | xs *title = xs_dup(content); |
| 1133 | int i = -1; | ||
| 1133 | 1134 | ||
| 1134 | /* escape tags */ | 1135 | /* escape tags */ |
| 1135 | content = xs_replace_i(content, "<", "<"); | 1136 | content = xs_replace_i(content, "<", "<"); |
| 1136 | content = xs_replace_i(content, ">", ">"); | 1137 | content = xs_replace_i(content, ">", ">"); |
| 1137 | 1138 | ||
| 1139 | if (strlen(title) > 40) | ||
| 1140 | title[i = 40] = '\0'; | ||
| 1141 | |||
| 1142 | if ((v = strchr(title, '<'))) | ||
| 1143 | title[i = (v - title)] = '\0'; | ||
| 1144 | |||
| 1145 | if ((v = strchr(title, '&'))) | ||
| 1146 | title[i = (v - title)] = '\0'; | ||
| 1147 | |||
| 1148 | if (i != -1) | ||
| 1149 | title = xs_str_cat(xs_strip(title), "..."); | ||
| 1150 | |||
| 1138 | xs *s = xs_fmt( | 1151 | xs *s = xs_fmt( |
| 1139 | "<item>\n" | 1152 | "<item>\n" |
| 1140 | "<title>%s</title>\n" | 1153 | "<title>%s</title>\n" |
| 1141 | "<link>%s</link>\n" | 1154 | "<link>%s</link>\n" |
| 1142 | "<description>%s</description>\n" | 1155 | "<description>%s</description>\n" |
| 1143 | "</item>\n", | 1156 | "</item>\n", |
| 1144 | xs_is_null(title) ? "..." : title, id, content | 1157 | title, id, content |
| 1145 | ); | 1158 | ); |
| 1146 | 1159 | ||
| 1147 | rss = xs_str_cat(rss, s); | 1160 | rss = xs_str_cat(rss, s); |