diff options
| author | default <nobody@localhost> | 2025-03-24 17:29:17 +0100 |
|---|---|---|
| committer | default <nobody@localhost> | 2025-03-24 17:29:17 +0100 |
| commit | 307aab92be9b9e0ea7676e05b1c752371ed0f7b9 (patch) | |
| tree | c83b159dc6022fe36e4fb2a8c55df17403508e89 | |
| parent | 91e0f144a67d2176e202ed6fe3f8b4a10f2ef4da (diff) | |
In replace_shortnames(), avoid repeated emojis.
| -rw-r--r-- | html.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -72,6 +72,9 @@ xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems, const char *p const xs_dict *v; int c = 0; + xs_set rep_emoji; + xs_set_init(&rep_emoji); + while (xs_list_next(tag_list, &v, &c)) { const char *t = xs_dict_get(v, "type"); @@ -79,6 +82,10 @@ xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems, const char *p const char *n = xs_dict_get(v, "name"); const xs_dict *i = xs_dict_get(v, "icon"); + /* avoid repeated emojis (Misskey seems to return this) */ + if (xs_set_add(&rep_emoji, n) == 0) + continue; + if (xs_is_string(n) && xs_is_dict(i)) { const char *u = xs_dict_get(i, "url"); const char *mt = xs_dict_get(i, "mediaType"); @@ -104,6 +111,8 @@ xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems, const char *p } } } + + xs_set_free(&rep_emoji); } return s; |