commit 307aab9

default  ·  2025-03-24 16:29:17 +0000 UTC
parent 91e0f14
In replace_shortnames(), avoid repeated emojis.
1 files changed,  +9, -0
M html.c
M html.c
+9, -0
 1@@ -72,6 +72,9 @@ xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems, const char *p
 2         const xs_dict *v;
 3         int c = 0;
 4 
 5+        xs_set rep_emoji;
 6+        xs_set_init(&rep_emoji);
 7+
 8         while (xs_list_next(tag_list, &v, &c)) {
 9             const char *t = xs_dict_get(v, "type");
10 
11@@ -79,6 +82,10 @@ xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems, const char *p
12                 const char *n = xs_dict_get(v, "name");
13                 const xs_dict *i = xs_dict_get(v, "icon");
14 
15+                /* avoid repeated emojis (Misskey seems to return this) */
16+                if (xs_set_add(&rep_emoji, n) == 0)
17+                    continue;
18+
19                 if (xs_is_string(n) && xs_is_dict(i)) {
20                     const char *u = xs_dict_get(i, "url");
21                     const char *mt = xs_dict_get(i, "mediaType");
22@@ -104,6 +111,8 @@ xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems, const char *p
23                 }
24             }
25         }
26+
27+        xs_set_free(&rep_emoji);
28     }
29 
30     return s;