aboutsummaryrefslogtreecommitdiff
path: root/format.c
diff options
context:
space:
mode:
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;