commit b19b715

default  ·  2025-02-14 07:58:59 +0000 UTC
parent 292b2fd
Disable "shortnames" of the image/svg+xml mediaType.
1 files changed,  +16, -10
M html.c
M html.c
+16, -10
 1@@ -69,7 +69,7 @@ xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems, const char *p
 2 
 3         xs *style = xs_fmt("height: %dem; width: %dem; vertical-align: middle;", ems, ems);
 4 
 5-        const char *v;
 6+        const xs_dict *v;
 7         int c = 0;
 8 
 9         while (xs_list_next(tag_list, &v, &c)) {
10@@ -77,19 +77,25 @@ xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems, const char *p
11 
12             if (t && strcmp(t, "Emoji") == 0) {
13                 const char *n = xs_dict_get(v, "name");
14-                const char *i = xs_dict_get(v, "icon");
15+                const xs_dict *i = xs_dict_get(v, "icon");
16 
17-                if (n && i) {
18+                if (xs_is_string(n) && xs_is_dict(i)) {
19                     const char *u = xs_dict_get(i, "url");
20-                    xs *url = make_url(u, proxy, 0);
21+                    const char *mt = xs_dict_get(i, "mediaType");
22+
23+                    if (xs_is_string(u) && xs_is_string(mt) && strcmp(mt, "image/svg+xml")) {
24+                        xs *url = make_url(u, proxy, 0);
25 
26-                    xs_html *img = xs_html_sctag("img",
27-                        xs_html_attr("loading", "lazy"),
28-                        xs_html_attr("src", url),
29-                        xs_html_attr("style", style));
30+                        xs_html *img = xs_html_sctag("img",
31+                            xs_html_attr("loading", "lazy"),
32+                            xs_html_attr("src", url),
33+                            xs_html_attr("style", style));
34 
35-                    xs *s1 = xs_html_render(img);
36-                    s = xs_replace_i(s, n, s1);
37+                        xs *s1 = xs_html_render(img);
38+                        s = xs_replace_i(s, n, s1);
39+                    }
40+                    else
41+                        s = xs_replace_i(s, n, "");
42                 }
43             }
44         }