commit be3be93
default
·
2025-02-28 08:05:05 +0000 UTC
parent 6776a73
SVG support can be enabled by setting enable_svg to true in server.json.
1 files changed,
+16,
-10
M
html.c
M
html.c
+16,
-10
1@@ -83,16 +83,20 @@ xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems, const char *p
2 const char *u = xs_dict_get(i, "url");
3 const char *mt = xs_dict_get(i, "mediaType");
4
5- if (xs_is_string(u) && xs_is_string(mt) && strcmp(mt, "image/svg+xml")) {
6- xs *url = make_url(u, proxy, 0);
7+ if (xs_is_string(u) && xs_is_string(mt)) {
8+ if (strcmp(mt, "image/svg+xml") == 0 && !xs_is_true(xs_dict_get(srv_config, "enable_svg")))
9+ s = xs_replace_i(s, n, "");
10+ else {
11+ xs *url = make_url(u, proxy, 0);
12
13- xs_html *img = xs_html_sctag("img",
14- xs_html_attr("loading", "lazy"),
15- xs_html_attr("src", url),
16- xs_html_attr("style", style));
17+ xs_html *img = xs_html_sctag("img",
18+ xs_html_attr("loading", "lazy"),
19+ xs_html_attr("src", url),
20+ xs_html_attr("style", style));
21
22- xs *s1 = xs_html_render(img);
23- s = xs_replace_i(s, n, s1);
24+ xs *s1 = xs_html_render(img);
25+ s = xs_replace_i(s, n, s1);
26+ }
27 }
28 else
29 s = xs_replace_i(s, n, "");
30@@ -2313,8 +2317,10 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
31 continue;
32
33 /* drop silently any attachment that may include JavaScript */
34- if (strcmp(type, "image/svg+xml") == 0 ||
35- strcmp(type, "text/html") == 0)
36+ if (strcmp(type, "text/html") == 0)
37+ continue;
38+
39+ if (strcmp(type, "image/svg+xml") == 0 && !xs_is_true(xs_dict_get(srv_config, "enable_svg")))
40 continue;
41
42 /* do this attachment include an icon? */