commit fbd81b6

green  ·  2025-03-26 00:40:14 +0000 UTC
parent 4408859
mime types for apng and svg check
2 files changed,  +4, -7
M html.c
M html.c
+3, -7
 1@@ -95,14 +95,10 @@ xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems, const char *p
 2                         // on akkoma instances mediaType is not present.
 3                         // but we need to to know if the image is an svg or not.
 4                         // for now, i just use the file extention, which may not be the most reliable...
 5-                        int is_svg = 0;
 6-                        if (xs_is_string(mt)) {
 7-                            is_svg = (strcmp(mt, "image/svg+xml") == 0);
 8-                        } else {
 9-                            is_svg = xs_endswith(u, ".svg");
10-                        }
11+                        if (!xs_is_string(mt))
12+                            mt = xs_mime_by_ext(u);
13 
14-                        if (is_svg && !xs_is_true(xs_dict_get(srv_config, "enable_svg")))
15+                        if (strcmp(mt, "image/svg+xml") == 0 && !xs_is_true(xs_dict_get(srv_config, "enable_svg")))
16                             s = xs_replace_i(s, n, "");
17                         else {
18                             xs *url = make_url(u, proxy, 0);
+1, -0
1@@ -38,6 +38,7 @@ const char *xs_mime_types[] = {
2     "ogv",      "video/ogg",
3     "opus",     "audio/ogg",
4     "png",      "image/png",
5+    "apng",     "image/apng",
6     "svg",      "image/svg+xml",
7     "svgz",     "image/svg+xml",
8     "txt",      "text/plain",