diff options
| -rw-r--r-- | html.c | 16 |
1 files changed, 9 insertions, 7 deletions
| @@ -1899,23 +1899,25 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 1899 | if (!xs_startswith(id, snac.actor)) | 1899 | if (!xs_startswith(id, snac.actor)) |
| 1900 | continue; | 1900 | continue; |
| 1901 | 1901 | ||
| 1902 | xs *es1 = sanitize(xs_dict_get(msg, "content")); | 1902 | xs *content = sanitize(xs_dict_get(msg, "content")); |
| 1903 | xs *content = encode_html(es1); | 1903 | |
| 1904 | // We SHOULD only use sanitized one for description. | ||
| 1905 | // So, only encode for feed title, while the description just keep it sanitized as is. | ||
| 1906 | xs *es_title_enc = encode_html(xs_dict_get(msg, "content")); | ||
| 1907 | xs *es_title = xs_replace(es_title_enc, "<br>", "\n"); | ||
| 1904 | xs *title = xs_str_new(NULL); | 1908 | xs *title = xs_str_new(NULL); |
| 1905 | int i; | 1909 | int i; |
| 1906 | 1910 | ||
| 1907 | for (i = 0; content[i] && content[i] != '<' && content[i] != '&' && i < 40; i++) | 1911 | for (i = 0; es_title[i] && es_title[i] != '\n' && i < 50; i++) |
| 1908 | title = xs_append_m(title, &content[i], 1); | 1912 | title = xs_append_m(title, &es_title[i], 1); |
| 1909 | 1913 | ||
| 1910 | xs *es11 = encode_html(title); | ||
| 1911 | xs *es12 = encode_html(content); | ||
| 1912 | xs *s = xs_fmt( | 1914 | xs *s = xs_fmt( |
| 1913 | "<item>\n" | 1915 | "<item>\n" |
| 1914 | "<title>%s...</title>\n" | 1916 | "<title>%s...</title>\n" |
| 1915 | "<link>%s</link>\n" | 1917 | "<link>%s</link>\n" |
| 1916 | "<description>%s</description>\n" | 1918 | "<description>%s</description>\n" |
| 1917 | "</item>\n", | 1919 | "</item>\n", |
| 1918 | es11, id, es12 | 1920 | title, id, content |
| 1919 | ); | 1921 | ); |
| 1920 | 1922 | ||
| 1921 | rss = xs_str_cat(rss, s); | 1923 | rss = xs_str_cat(rss, s); |