diff options
Diffstat (limited to 'rss.c')
| -rw-r--r-- | rss.c | 14 |
1 files changed, 11 insertions, 3 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* snac - A simple, minimalistic ActivityPub instance */ | 1 | /* snac - A simple, minimalistic ActivityPub instance */ |
| 2 | /* copyright (c) 2025 grunfink et al. / MIT license */ | 2 | /* copyright (c) 2025 - 2026 grunfink et al. / MIT license */ |
| 3 | 3 | ||
| 4 | #include "xs.h" | 4 | #include "xs.h" |
| 5 | #include "xs_html.h" | 5 | #include "xs_html.h" |
| @@ -10,6 +10,7 @@ | |||
| 10 | #include "xs_openssl.h" | 10 | #include "xs_openssl.h" |
| 11 | #include "xs_json.h" | 11 | #include "xs_json.h" |
| 12 | #include "xs_http.h" | 12 | #include "xs_http.h" |
| 13 | #include "xs_unicode.h" | ||
| 13 | 14 | ||
| 14 | #include "snac.h" | 15 | #include "snac.h" |
| 15 | 16 | ||
| @@ -59,7 +60,7 @@ xs_str *rss_from_timeline(snac *user, const xs_list *timeline, | |||
| 59 | const char *content = xs_dict_get(msg, "content"); | 60 | const char *content = xs_dict_get(msg, "content"); |
| 60 | const char *published = xs_dict_get(msg, "published"); | 61 | const char *published = xs_dict_get(msg, "published"); |
| 61 | 62 | ||
| 62 | if (user && !xs_startswith(id, user->actor)) | 63 | if (user && !is_msg_mine(user, id)) |
| 63 | continue; | 64 | continue; |
| 64 | 65 | ||
| 65 | if (!id || !content || !published) | 66 | if (!id || !content || !published) |
| @@ -74,7 +75,14 @@ xs_str *rss_from_timeline(snac *user, const xs_list *timeline, | |||
| 74 | title = xs_regex_replace_i(title, "&[^;]+;", " "); | 75 | title = xs_regex_replace_i(title, "&[^;]+;", " "); |
| 75 | int i; | 76 | int i; |
| 76 | 77 | ||
| 77 | for (i = 0; title[i] && title[i] != '\n' && i < 50; i++); | 78 | for (i = 0; title[i] && title[i] != '\n' && i < 50; ) { |
| 79 | const char *p = &title[i]; | ||
| 80 | unsigned int cp = xs_utf8_dec(&p); | ||
| 81 | int n = p - title; | ||
| 82 | if (cp == 0xfffd || n > 50) | ||
| 83 | break; | ||
| 84 | i = n; | ||
| 85 | } | ||
| 78 | 86 | ||
| 79 | if (title[i] != '\0') { | 87 | if (title[i] != '\0') { |
| 80 | title[i] = '\0'; | 88 | title[i] = '\0'; |