diff options
| author | 2026-01-24 21:33:30 +0100 | |
|---|---|---|
| committer | 2026-01-24 21:33:30 +0100 | |
| commit | bfd071c63826f4d13d48614cedebfb2f8ea20cf6 (patch) | |
| tree | 8cc9b766b88fa66d051e55d65d6694570553a17b /format.c | |
| parent | Added a Follow/Unfollow button next to a new follow notification. (diff) | |
| parent | Merge pull request 'add susie-q (qr) to artwork' (#528) from pmjv/snac2:maste... (diff) | |
| download | snac2-bfd071c63826f4d13d48614cedebfb2f8ea20cf6.tar.gz snac2-bfd071c63826f4d13d48614cedebfb2f8ea20cf6.tar.xz snac2-bfd071c63826f4d13d48614cedebfb2f8ea20cf6.zip | |
Merge pull request 'master' (#7) from grunfink/snac2:master into main
Reviewed-on: https://codeberg.org/byte/snac2/pulls/7
Diffstat (limited to 'format.c')
| -rw-r--r-- | format.c | 25 |
1 files changed, 23 insertions, 2 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* snac - A simple, minimalistic ActivityPub instance */ | 1 | /* snac - A simple, minimalistic ActivityPub instance */ |
| 2 | /* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ | 2 | /* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ |
| 3 | 3 | ||
| 4 | #include "xs.h" | 4 | #include "xs.h" |
| 5 | #include "xs_regex.h" | 5 | #include "xs_regex.h" |
| @@ -79,6 +79,24 @@ xs_dict *emojis(void) | |||
| 79 | return d; | 79 | return d; |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | |||
| 83 | xs_dict *emojis_rm_categories() { | ||
| 84 | xs *emjs = emojis(); | ||
| 85 | char *res = xs_dict_new(); | ||
| 86 | const char *k, *v; | ||
| 87 | xs_dict_foreach(emjs, k, v) { | ||
| 88 | if (xs_type(v) == XSTYPE_DICT) { | ||
| 89 | const char *v2; | ||
| 90 | xs_dict_foreach(v, k, v2) | ||
| 91 | res = xs_dict_append(res, k, v2); | ||
| 92 | } | ||
| 93 | else | ||
| 94 | res = xs_dict_append(res, k, v); | ||
| 95 | } | ||
| 96 | return res; | ||
| 97 | } | ||
| 98 | |||
| 99 | |||
| 82 | /* Non-whitespace without trailing comma, period or closing paren */ | 100 | /* Non-whitespace without trailing comma, period or closing paren */ |
| 83 | #define NOSPACE "([^[:space:],.)]+|[,.)]+[^[:space:],.)])+" | 101 | #define NOSPACE "([^[:space:],.)]+|[,.)]+[^[:space:],.)])+" |
| 84 | 102 | ||
| @@ -405,7 +423,7 @@ xs_str *not_really_markdown(const char *content, xs_list **attach, xs_list **tag | |||
| 405 | 423 | ||
| 406 | { | 424 | { |
| 407 | /* traditional emoticons */ | 425 | /* traditional emoticons */ |
| 408 | xs *d = emojis(); | 426 | xs *d = emojis_rm_categories(); |
| 409 | int c = 0; | 427 | int c = 0; |
| 410 | const char *k, *v; | 428 | const char *k, *v; |
| 411 | 429 | ||
| @@ -459,6 +477,9 @@ xs_str *sanitize(const char *content) | |||
| 459 | char *p; | 477 | char *p; |
| 460 | const char *v; | 478 | const char *v; |
| 461 | 479 | ||
| 480 | if (!content) | ||
| 481 | return NULL; | ||
| 482 | |||
| 462 | sl = xs_regex_split(content, "</?[^>]+>"); | 483 | sl = xs_regex_split(content, "</?[^>]+>"); |
| 463 | 484 | ||
| 464 | p = sl; | 485 | p = sl; |