aboutsummaryrefslogtreecommitdiff
path: root/format.c
diff options
context:
space:
mode:
authorbyte <byte@noreply.codeberg.org>2026-01-24 21:33:30 +0100
committerbyte <byte@noreply.codeberg.org>2026-01-24 21:33:30 +0100
commitbfd071c63826f4d13d48614cedebfb2f8ea20cf6 (patch)
tree8cc9b766b88fa66d051e55d65d6694570553a17b /format.c
parentd4137522487235180528281ee64b7c5963f63ebe (diff)
parentc6b411ac34e80505517bf120153017ec42943d4e (diff)
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.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/format.c b/format.c
index 84c634d..95c1b12 100644
--- a/format.c
+++ b/format.c
@@ -1,5 +1,5 @@
/* snac - A simple, minimalistic ActivityPub instance */
-/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */
+/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */
#include "xs.h"
#include "xs_regex.h"
@@ -79,6 +79,24 @@ xs_dict *emojis(void)
return d;
}
+
+xs_dict *emojis_rm_categories() {
+ xs *emjs = emojis();
+ char *res = xs_dict_new();
+ const char *k, *v;
+ xs_dict_foreach(emjs, k, v) {
+ if (xs_type(v) == XSTYPE_DICT) {
+ const char *v2;
+ xs_dict_foreach(v, k, v2)
+ res = xs_dict_append(res, k, v2);
+ }
+ else
+ res = xs_dict_append(res, k, v);
+ }
+ return res;
+}
+
+
/* Non-whitespace without trailing comma, period or closing paren */
#define NOSPACE "([^[:space:],.)]+|[,.)]+[^[:space:],.)])+"
@@ -405,7 +423,7 @@ xs_str *not_really_markdown(const char *content, xs_list **attach, xs_list **tag
{
/* traditional emoticons */
- xs *d = emojis();
+ xs *d = emojis_rm_categories();
int c = 0;
const char *k, *v;
@@ -459,6 +477,9 @@ xs_str *sanitize(const char *content)
char *p;
const char *v;
+ if (!content)
+ return NULL;
+
sl = xs_regex_split(content, "</?[^>]+>");
p = sl;