summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
authorgrunfink <grunfink@noreply.codeberg.org>2023-07-26 06:13:55 +0000
committergrunfink <grunfink@noreply.codeberg.org>2023-07-26 06:13:55 +0000
commitb22786bd55d5e9638710567a311e9855c31db681 (patch)
tree642c4974ea7370bdd07141f84709fa080c45ed92 /html.c
parent52d3b5c8db94dbf986b7c3c388948f37e657499e (diff)
parentb2a274df763da005f208f07574d1cb7d082834b1 (diff)
Merge pull request 'html.c: Fix non-list tag object for external custom emoji' (#77) from yonle/snac2:master into master
Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/77
Diffstat (limited to 'html.c')
-rw-r--r--html.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/html.c b/html.c
index 976a244..bf2f181 100644
--- a/html.c
+++ b/html.c
@@ -56,8 +56,20 @@ xs_str *actor_name(xs_dict *actor)
/* replace the :shortnames: */
if (!xs_is_null(p = xs_dict_get(actor, "tag"))) {
+ xs *tag = NULL;
+ if (xs_type(p) == XSTYPE_DICT) {
+ /* not a list */
+ tag = xs_list_new();
+ tag = xs_list_append(tag, p);
+ } else {
+ /* is a list */
+ tag = xs_dup(p);
+ }
+
+ xs_list *tags = tag;
+
/* iterate the tags */
- while (xs_list_iter(&p, &v)) {
+ while (xs_list_iter(&tags, &v)) {
char *t = xs_dict_get(v, "type");
if (t && strcmp(t, "Emoji") == 0) {
@@ -1031,8 +1043,20 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
/* replace the :shortnames: */
if (!xs_is_null(p = xs_dict_get(msg, "tag"))) {
+ xs *tag = NULL;
+ if (xs_type(p) == XSTYPE_DICT) {
+ /* not a list */
+ tag = xs_list_new();
+ tag = xs_list_append(tag, p);
+ } else {
+ /* is a list */
+ tag = xs_dup(p);
+ }
+
+ xs_list *tags = tag;
+
/* iterate the tags */
- while (xs_list_iter(&p, &v)) {
+ while (xs_list_iter(&tags, &v)) {
char *t = xs_dict_get(v, "type");
if (t && strcmp(t, "Emoji") == 0) {