From 24105f6e9759b74c04522de1de12ddb77cfba568 Mon Sep 17 00:00:00 2001 From: postscriptum Date: Thu, 22 May 2025 03:34:48 +0300 Subject: use utf-8 lowercase function for tags #396 --- activitypub.c | 2 +- data.c | 4 ++-- format.c | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/activitypub.c b/activitypub.c index a7e133a..3ff51ad 100644 --- 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("%s", h, v); diff --git a/data.c b/data.c index e3fa52d..d5dc171 100644 --- 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 index 2f30a0d..0f844cd 100644 --- 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; -- cgit v1.2.3 From e567736640da21d37848567cd164cb84bbdab507 Mon Sep 17 00:00:00 2001 From: postscriptum Date: Thu, 22 May 2025 04:16:28 +0300 Subject: add missed replacement to the `content_match` function --- data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data.c b/data.c index d5dc171..8ca271d 100644 --- a/data.c +++ b/data.c @@ -2817,7 +2817,7 @@ int content_match(const char *file, const xs_dict *msg) /* massage content (strip HTML tags, etc.) */ xs *c = xs_regex_replace(v, "<[^>]+>", " "); c = xs_regex_replace_i(c, " {2,}", " "); - c = xs_tolower_i(c); + c = xs_utf8_to_lower(c); while (!r && !feof(f)) { xs *rx = xs_strip_i(xs_readline(f)); -- cgit v1.2.3 From ec37139f5aac4f54d09f768c54195fb528fd3088 Mon Sep 17 00:00:00 2001 From: postscriptum Date: Thu, 22 May 2025 04:35:52 +0300 Subject: cleanup ending spaces --- mastoapi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mastoapi.c b/mastoapi.c index 7fa0078..dee73e8 100644 --- a/mastoapi.c +++ b/mastoapi.c @@ -381,7 +381,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, } } - /* no code? + /* no code? I'm not sure of the impacts of this right now, but Subway Tooter does not provide a code so one must be generated */ if (xs_is_null(code)){ @@ -1780,7 +1780,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, } else if (strcmp(opt, "statuses") == 0) { - /* we don't serve statuses of others; return the empty list */ + /* we don't serve statuses of others; return the empty list */ out = xs_list_new(); } else @@ -1999,7 +1999,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, } else if (strcmp(cmd, "/v2/filters") == 0) { /** **/ - /* snac will never have filters + /* snac will never have filters * but still, without a v2 endpoint a short delay is introduced * in some apps */ *body = xs_dup("[]"); @@ -2459,7 +2459,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, if (logged_in) { const xs_list *timeline = xs_dict_get(args, "timeline[]"); xs_str *json = NULL; - if (!xs_is_null(timeline)) + if (!xs_is_null(timeline)) json = xs_json_dumps(markers_get(&snac1, timeline), 4); if (!xs_is_null(json)) @@ -3227,7 +3227,7 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, if (!xs_is_null(home)) home_marker = xs_dict_get(home, "last_read_id"); } - + const xs_str *notify_marker = xs_dict_get(args, "notifications[last_read_id]"); if (xs_is_null(notify_marker)) { const xs_dict *notify = xs_dict_get(args, "notifications"); -- cgit v1.2.3 From 450e679f5197cfe3101d2b3f032f3fabeadfc848 Mon Sep 17 00:00:00 2001 From: postscriptum Date: Thu, 22 May 2025 04:37:13 +0300 Subject: add missed replacement to the `mastoapi_get_handler` function (`search` case) --- mastoapi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mastoapi.c b/mastoapi.c index dee73e8..0348ec6 100644 --- a/mastoapi.c +++ b/mastoapi.c @@ -15,6 +15,7 @@ #include "xs_url.h" #include "xs_mime.h" #include "xs_match.h" +#include "xs_unicode.h" #include "snac.h" @@ -1637,7 +1638,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, const char *aq = xs_dict_get(args, "q"); if (!xs_is_null(aq)) { - xs *q = xs_tolower_i(xs_dup(aq)); + xs *q = xs_utf8_to_lower(xs_dup(aq)); out = xs_list_new(); xs *wing = following_list(&snac1); xs *wers = follower_list(&snac1); -- cgit v1.2.3