summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
authorGravatar default2025-02-28 09:05:05 +0100
committerGravatar default2025-02-28 09:05:05 +0100
commitbe3be930ad95dd58a32d8bae0a0bbe5bd5966219 (patch)
tree77cc8a0ae6171aff1337e8f6e88d516f174d6d9c /html.c
parentSome tweaks to timeline_request(). (diff)
downloadsnac2-be3be930ad95dd58a32d8bae0a0bbe5bd5966219.tar.gz
snac2-be3be930ad95dd58a32d8bae0a0bbe5bd5966219.tar.xz
snac2-be3be930ad95dd58a32d8bae0a0bbe5bd5966219.zip
SVG support can be enabled by setting enable_svg to true in server.json.
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 92a81cc..cb30eec 100644
--- a/html.c
+++ b/html.c
@@ -83,16 +83,20 @@ xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems, const char *p
83 const char *u = xs_dict_get(i, "url"); 83 const char *u = xs_dict_get(i, "url");
84 const char *mt = xs_dict_get(i, "mediaType"); 84 const char *mt = xs_dict_get(i, "mediaType");
85 85
86 if (xs_is_string(u) && xs_is_string(mt) && strcmp(mt, "image/svg+xml")) { 86 if (xs_is_string(u) && xs_is_string(mt)) {
87 xs *url = make_url(u, proxy, 0); 87 if (strcmp(mt, "image/svg+xml") == 0 && !xs_is_true(xs_dict_get(srv_config, "enable_svg")))
88 s = xs_replace_i(s, n, "");
89 else {
90 xs *url = make_url(u, proxy, 0);
88 91
89 xs_html *img = xs_html_sctag("img", 92 xs_html *img = xs_html_sctag("img",
90 xs_html_attr("loading", "lazy"), 93 xs_html_attr("loading", "lazy"),
91 xs_html_attr("src", url), 94 xs_html_attr("src", url),
92 xs_html_attr("style", style)); 95 xs_html_attr("style", style));
93 96
94 xs *s1 = xs_html_render(img); 97 xs *s1 = xs_html_render(img);
95 s = xs_replace_i(s, n, s1); 98 s = xs_replace_i(s, n, s1);
99 }
96 } 100 }
97 else 101 else
98 s = xs_replace_i(s, n, ""); 102 s = xs_replace_i(s, n, "");
@@ -2313,8 +2317,10 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
2313 continue; 2317 continue;
2314 2318
2315 /* drop silently any attachment that may include JavaScript */ 2319 /* drop silently any attachment that may include JavaScript */
2316 if (strcmp(type, "image/svg+xml") == 0 || 2320 if (strcmp(type, "text/html") == 0)
2317 strcmp(type, "text/html") == 0) 2321 continue;
2322
2323 if (strcmp(type, "image/svg+xml") == 0 && !xs_is_true(xs_dict_get(srv_config, "enable_svg")))
2318 continue; 2324 continue;
2319 2325
2320 /* do this attachment include an icon? */ 2326 /* do this attachment include an icon? */