summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
authorGravatar default2025-02-14 08:58:59 +0100
committerGravatar default2025-02-14 08:58:59 +0100
commitb19b7154534c04de68792175e19eeacbcefe7c44 (patch)
treeec11fb2bb8fb321fac6ab0c2a5921fe0902df398 /html.c
parentForce the Content-Security-Policy header, instead of just suggesting it in th... (diff)
downloadsnac2-b19b7154534c04de68792175e19eeacbcefe7c44.tar.gz
snac2-b19b7154534c04de68792175e19eeacbcefe7c44.tar.xz
snac2-b19b7154534c04de68792175e19eeacbcefe7c44.zip
Disable "shortnames" of the image/svg+xml mediaType.
Diffstat (limited to 'html.c')
-rw-r--r--html.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/html.c b/html.c
index d713fbb..e45b0b2 100644
--- a/html.c
+++ b/html.c
@@ -69,7 +69,7 @@ xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems, const char *p
69 69
70 xs *style = xs_fmt("height: %dem; width: %dem; vertical-align: middle;", ems, ems); 70 xs *style = xs_fmt("height: %dem; width: %dem; vertical-align: middle;", ems, ems);
71 71
72 const char *v; 72 const xs_dict *v;
73 int c = 0; 73 int c = 0;
74 74
75 while (xs_list_next(tag_list, &v, &c)) { 75 while (xs_list_next(tag_list, &v, &c)) {
@@ -77,19 +77,25 @@ xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems, const char *p
77 77
78 if (t && strcmp(t, "Emoji") == 0) { 78 if (t && strcmp(t, "Emoji") == 0) {
79 const char *n = xs_dict_get(v, "name"); 79 const char *n = xs_dict_get(v, "name");
80 const char *i = xs_dict_get(v, "icon"); 80 const xs_dict *i = xs_dict_get(v, "icon");
81 81
82 if (n && i) { 82 if (xs_is_string(n) && xs_is_dict(i)) {
83 const char *u = xs_dict_get(i, "url"); 83 const char *u = xs_dict_get(i, "url");
84 xs *url = make_url(u, proxy, 0); 84 const char *mt = xs_dict_get(i, "mediaType");
85
86 if (xs_is_string(u) && xs_is_string(mt) && strcmp(mt, "image/svg+xml")) {
87 xs *url = make_url(u, proxy, 0);
85 88
86 xs_html *img = xs_html_sctag("img", 89 xs_html *img = xs_html_sctag("img",
87 xs_html_attr("loading", "lazy"), 90 xs_html_attr("loading", "lazy"),
88 xs_html_attr("src", url), 91 xs_html_attr("src", url),
89 xs_html_attr("style", style)); 92 xs_html_attr("style", style));
90 93
91 xs *s1 = xs_html_render(img); 94 xs *s1 = xs_html_render(img);
92 s = xs_replace_i(s, n, s1); 95 s = xs_replace_i(s, n, s1);
96 }
97 else
98 s = xs_replace_i(s, n, "");
93 } 99 }
94 } 100 }
95 } 101 }