snac2

Fork of https://codeberg.org/grunfink/snac2
git clone https://git.inz.fi/snac2
Log | Files | Refs | README | LICENSE

commit 24105f6e9759b74c04522de1de12ddb77cfba568
parent 072ae21013dc924c6bb3378a2480b571a66aba98
Author: postscriptum <postscriptum@project>
Date:   Thu, 22 May 2025 03:34:48 +0300

use utf-8 lowercase function for tags #396

Diffstat:
Mactivitypub.c | 2+-
Mdata.c | 4++--
Mformat.c | 3++-
3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/activitypub.c b/activitypub.c @@ -903,7 +903,7 @@ xs_str *process_tags(snac *snac, const char *content, xs_list **tag) if (*v == '#') { /* hashtag */ xs *d = xs_dict_new(); - xs *n = xs_tolower_i(xs_dup(v)); + xs *n = xs_utf8_to_lower(xs_dup(v)); xs *h = xs_fmt("%s?t=%s", srv_baseurl, n + 1); xs *l = xs_fmt("<a href=\"%s\" class=\"mention hashtag\" rel=\"tag\">%s</a>", h, v); diff --git a/data.c b/data.c @@ -2200,7 +2200,7 @@ void tag_index(const char *id, const xs_dict *obj) if (*name == '\0') continue; - name = xs_tolower_i((xs_str *)name); + name = xs_utf8_to_lower((xs_str *)name); xs *md5_tag = xs_md5_hex(name, strlen(name)); xs *tag_dir = xs_fmt("%s/%c%c", g_tag_dir, md5_tag[0], md5_tag[1]); @@ -2230,7 +2230,7 @@ xs_str *tag_fn(const char *tag) if (*tag == '#') tag++; - xs *lw_tag = xs_tolower_i(xs_dup(tag)); + xs *lw_tag = xs_utf8_to_lower(xs_dup(tag)); xs *md5 = xs_md5_hex(lw_tag, strlen(lw_tag)); return xs_fmt("%s/tag/%c%c/%s.idx", srv_basedir, md5[0], md5[1], md5); diff --git a/format.c b/format.c @@ -8,6 +8,7 @@ #include "xs_json.h" #include "xs_time.h" #include "xs_match.h" +#include "xs_unicode.h" #include "snac.h" @@ -443,7 +444,7 @@ xs_str *sanitize(const char *content) if (n & 0x1) { xs *s1 = xs_strip_i(xs_crop_i(xs_dup(v), v[1] == '/' ? 2 : 1, -1)); xs *l1 = xs_split_n(s1, " ", 1); - xs *tag = xs_tolower_i(xs_dup(xs_list_get(l1, 0))); + xs *tag = xs_utf8_to_lower(xs_dup(xs_list_get(l1, 0))); xs *s2 = NULL; int i;