diff options
| author | 2025-04-06 07:44:12 +0200 | |
|---|---|---|
| committer | 2025-04-06 07:44:12 +0200 | |
| commit | 7f7d42c52db934da6af8d3cdd7c03dd95a08cbaf (patch) | |
| tree | 0abc7a30a14cecbd5cacf9d46ee580ffdd412775 /html.c | |
| parent | Use <hr hidden> instead of 'display: none' style. (diff) | |
| download | snac2-7f7d42c52db934da6af8d3cdd7c03dd95a08cbaf.tar.gz snac2-7f7d42c52db934da6af8d3cdd7c03dd95a08cbaf.tar.xz snac2-7f7d42c52db934da6af8d3cdd7c03dd95a08cbaf.zip | |
Post attachments now have random names.
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 8 |
1 files changed, 6 insertions, 2 deletions
| @@ -14,6 +14,7 @@ | |||
| 14 | #include "xs_curl.h" | 14 | #include "xs_curl.h" |
| 15 | #include "xs_unicode.h" | 15 | #include "xs_unicode.h" |
| 16 | #include "xs_url.h" | 16 | #include "xs_url.h" |
| 17 | #include "xs_random.h" | ||
| 17 | 18 | ||
| 18 | #include "snac.h" | 19 | #include "snac.h" |
| 19 | 20 | ||
| @@ -4286,9 +4287,12 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 4286 | const char *fn = xs_list_get(attach_file, 0); | 4287 | const char *fn = xs_list_get(attach_file, 0); |
| 4287 | 4288 | ||
| 4288 | if (xs_is_string(fn) && *fn != '\0') { | 4289 | if (xs_is_string(fn) && *fn != '\0') { |
| 4290 | char rnd[32]; | ||
| 4291 | xs_rnd_buf(rnd, sizeof(rnd)); | ||
| 4292 | |||
| 4289 | char *ext = strrchr(fn, '.'); | 4293 | char *ext = strrchr(fn, '.'); |
| 4290 | xs *hash = xs_md5_hex(fn, strlen(fn)); | 4294 | xs *hash = xs_md5_hex(rnd, strlen(rnd)); |
| 4291 | xs *id = xs_fmt("%s%s", hash, ext); | 4295 | xs *id = xs_fmt("p-%s%s", hash, ext ? ext : ""); |
| 4292 | xs *url = xs_fmt("%s/s/%s", snac.actor, id); | 4296 | xs *url = xs_fmt("%s/s/%s", snac.actor, id); |
| 4293 | int fo = xs_number_get(xs_list_get(attach_file, 1)); | 4297 | int fo = xs_number_get(xs_list_get(attach_file, 1)); |
| 4294 | int fs = xs_number_get(xs_list_get(attach_file, 2)); | 4298 | int fs = xs_number_get(xs_list_get(attach_file, 2)); |