diff options
| author | Oliver <zen@noreply.codeberg.org> | 2025-05-21 21:11:47 +0200 |
|---|---|---|
| committer | Oliver <zen@noreply.codeberg.org> | 2025-05-21 21:11:47 +0200 |
| commit | 979718e3cc5489efdce2acc6f8c86f6d00bb91c7 (patch) | |
| tree | 7b4936bdb5ea07c7dd617d508c487d70020f0146 /format.c | |
| parent | 1b0804bb0da0ef89aef98d9a771d2aa5bfeb34d7 (diff) | |
| parent | 5059fadf34b79a9f596313b0bd859c1eb89342ae (diff) | |
Merge pull request 'master refresh' (#8) from grunfink/snac2:master into master
Reviewed-on: https://codeberg.org/zen/snac2/pulls/8
Diffstat (limited to 'format.c')
| -rw-r--r-- | format.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -154,8 +154,10 @@ static xs_str *format_line(const char *line, xs_list **attach) xs *l = xs_split_n(w, "](", 1); if (xs_list_len(l) == 2) { - xs *link = xs_fmt("<a href=\"%s\">%s</a>", - xs_list_get(l, 1), xs_list_get(l, 0)); + const char *name = xs_list_get(l, 0); + const char *url = xs_list_get(l, 1); + + xs *link = xs_fmt("<a href=\"%s\">%s</a>", url, name); s = xs_str_cat(s, link); } @@ -208,6 +210,7 @@ static xs_str *format_line(const char *line, xs_list **attach) } else if (xs_str_in(v, ":/" "/") != -1) { + /* direct URLs in the post body */ xs *u = xs_replace_i(xs_replace(v, "#", "#"), "@", "@"); xs *v2 = xs_strip_chars_i(xs_dup(u), ".,)"); @@ -382,10 +385,11 @@ xs_str *not_really_markdown(const char *content, xs_list **attach, xs_list **tag const char *k, *v; while (xs_dict_next(d, &k, &v, &c)) { - const char *t = NULL; + const char *t = xs_mime_by_ext(v); /* is it an URL to an image? */ - if (xs_startswith(v, "https:/" "/") && xs_startswith((t = xs_mime_by_ext(v)), "image/")) { + if (xs_startswith(v, "https:/" "/") && + (xs_startswith(t, "image/") || strcmp(t, "application/octet-stream") == 0)) { if (tag && xs_str_in(s, k) != -1) { /* add the emoji to the tag list */ xs *e = xs_dict_new(); |