commit b2a274d

Yonle  ·  2023-07-25 16:33:14 +0000 UTC
parent 52d3b5c
html.c: Fix non-list tag object for external custom emoji

Signed-off-by: Yonle <yonle@lecturify.net>
1 files changed,  +26, -2
M html.c
M html.c
+26, -2
 1@@ -56,8 +56,20 @@ xs_str *actor_name(xs_dict *actor)
 2 
 3     /* replace the :shortnames: */
 4     if (!xs_is_null(p = xs_dict_get(actor, "tag"))) {
 5+        xs *tag = NULL;
 6+        if (xs_type(p) == XSTYPE_DICT) {
 7+            /* not a list */
 8+            tag = xs_list_new();
 9+            tag = xs_list_append(tag, p);
10+        } else {
11+            /* is a list */
12+            tag = xs_dup(p);
13+        }
14+
15+        xs_list *tags = tag;
16+
17         /* iterate the tags */
18-        while (xs_list_iter(&p, &v)) {
19+        while (xs_list_iter(&tags, &v)) {
20             char *t = xs_dict_get(v, "type");
21 
22             if (t && strcmp(t, "Emoji") == 0) {
23@@ -1031,8 +1043,20 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
24 
25         /* replace the :shortnames: */
26         if (!xs_is_null(p = xs_dict_get(msg, "tag"))) {
27+            xs *tag = NULL;
28+            if (xs_type(p) == XSTYPE_DICT) {
29+                /* not a list */
30+                tag = xs_list_new();
31+                tag = xs_list_append(tag, p);
32+            } else {
33+                /* is a list */
34+                tag = xs_dup(p);
35+            }
36+
37+            xs_list *tags = tag;
38+
39             /* iterate the tags */
40-            while (xs_list_iter(&p, &v)) {
41+            while (xs_list_iter(&tags, &v)) {
42                 char *t = xs_dict_get(v, "type");
43 
44                 if (t && strcmp(t, "Emoji") == 0) {