diff options
| author | 2025-04-18 23:32:05 +0000 | |
|---|---|---|
| committer | 2025-05-23 21:13:22 +0000 | |
| commit | c110edce88cb3303b4d412b4e8802602fdf64a71 (patch) | |
| tree | 167eb0d33c80c6277de21109f2f7df7e901ef7be /html.c | |
| parent | Modified generated HTML to match my stylesheet ehheh (diff) | |
| download | penes-snac2-c110edce88cb3303b4d412b4e8802602fdf64a71.tar.gz penes-snac2-c110edce88cb3303b4d412b4e8802602fdf64a71.tar.xz penes-snac2-c110edce88cb3303b4d412b4e8802602fdf64a71.zip | |
Fix custom emojis not appearing
This fixes emojis not appearing if source instance hasn't set the mediaType field.
We use xs_mime_by_ext in order to guess whether the file is SVG or not when mediaType is missing.
This commit also changes the behaviour to not replace :shortnames: with nothing when the emoji replacement failed.
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 14 |
1 files changed, 8 insertions, 6 deletions
| @@ -91,10 +91,14 @@ xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems, const char *p | |||
| 91 | const char *u = xs_dict_get(i, "url"); | 91 | const char *u = xs_dict_get(i, "url"); |
| 92 | const char *mt = xs_dict_get(i, "mediaType"); | 92 | const char *mt = xs_dict_get(i, "mediaType"); |
| 93 | 93 | ||
| 94 | if (xs_is_string(u) && xs_is_string(mt)) { | 94 | if (xs_is_string(u)) { |
| 95 | if (strcmp(mt, "image/svg+xml") == 0 && !xs_is_true(xs_dict_get(srv_config, "enable_svg"))) | 95 | if (!xs_is_string(mt)) |
| 96 | s = xs_replace_i(s, n, ""); | 96 | mt = xs_mime_by_ext(u); |
| 97 | else { | 97 | |
| 98 | if (!xs_startswith(mt, "image/")) | ||
| 99 | continue; | ||
| 100 | |||
| 101 | if (strcmp(mt, "image/svg+xml") != 0 || xs_is_true(xs_dict_get(srv_config, "enable_svg"))) { | ||
| 98 | xs *url = make_url(u, proxy, 0); | 102 | xs *url = make_url(u, proxy, 0); |
| 99 | 103 | ||
| 100 | xs_html *img = xs_html_sctag("img", | 104 | xs_html *img = xs_html_sctag("img", |
| @@ -109,8 +113,6 @@ xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems, const char *p | |||
| 109 | s = xs_replace_i(s, n, s1); | 113 | s = xs_replace_i(s, n, s1); |
| 110 | } | 114 | } |
| 111 | } | 115 | } |
| 112 | else | ||
| 113 | s = xs_replace_i(s, n, ""); | ||
| 114 | } | 116 | } |
| 115 | } | 117 | } |
| 116 | } | 118 | } |