green 1 год назад
Родитель
Сommit
7f10057cff
1 измененных файлов с 16 добавлено и 2 удалено
  1. 16 2
      html.c

+ 16 - 2
html.c

@@ -91,8 +91,18 @@ xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems, const char *p
                     const char *u = xs_dict_get(i, "url");
                     const char *mt = xs_dict_get(i, "mediaType");
 
-                    if (xs_is_string(u) && xs_is_string(mt)) {
-                        if (strcmp(mt, "image/svg+xml") == 0 && !xs_is_true(xs_dict_get(srv_config, "enable_svg")))
+                    if (xs_is_string(u)) {
+                        // on akkoma instances mediaType is not present.
+                        // but we need to to know if the image is an svg or not.
+                        // for now, i just use the file extention, which may not be the most reliable...
+                        int is_svg = 0;
+                        if (xs_is_string(mt)) {
+                            is_svg = (strcmp(mt, "image/svg+xml") == 0);
+                        } else {
+                            is_svg = xs_endswith(u, ".svg");
+                        }
+
+                        if (is_svg && !xs_is_true(xs_dict_get(srv_config, "enable_svg")))
                             s = xs_replace_i(s, n, "");
                         else {
                             xs *url = make_url(u, proxy, 0);
@@ -3112,6 +3122,10 @@ xs_html *html_people_list(snac *user, xs_list *list, const char *header, const c
 
             if (!xs_is_null(c)) {
                 xs *sc = sanitize(c);
+
+                // replace shortnames in bio
+                // bug: this somehow fires twice on one specific user
+                // @ielenia@ck.catwithaclari.net
                 sc = replace_shortnames(sc, xs_dict_get(actor, "tag"), 2, proxy);
 
                 xs_html *snac_content = xs_html_tag("div",