From 307aab92be9b9e0ea7676e05b1c752371ed0f7b9 Mon Sep 17 00:00:00 2001 From: default Date: Mon, 24 Mar 2025 17:29:17 +0100 Subject: In replace_shortnames(), avoid repeated emojis. --- html.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/html.c b/html.c index 78a9854..abb8562 100644 --- a/html.c +++ b/html.c @@ -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; -- cgit v1.2.3