commit 096bb21
Merge pull request 'use utf-8 lowercase function for tags #396' (#400) from postscriptum/snac2:utf8-lower-tags into master Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/400
4 files changed,
+13,
-11
+1,
-1
1@@ -903,7 +903,7 @@ xs_str *process_tags(snac *snac, const char *content, xs_list **tag)
2 if (*v == '#') {
3 /* hashtag */
4 xs *d = xs_dict_new();
5- xs *n = xs_tolower_i(xs_dup(v));
6+ xs *n = xs_utf8_to_lower(xs_dup(v));
7 xs *h = xs_fmt("%s?t=%s", srv_baseurl, n + 1);
8 xs *l = xs_fmt("<a href=\"%s\" class=\"mention hashtag\" rel=\"tag\">%s</a>", h, v);
9
M
data.c
+3,
-3
1@@ -2217,7 +2217,7 @@ void tag_index(const char *id, const xs_dict *obj)
2 if (*name == '\0')
3 continue;
4
5- name = xs_tolower_i((xs_str *)name);
6+ name = xs_utf8_to_lower((xs_str *)name);
7
8 xs *md5_tag = xs_md5_hex(name, strlen(name));
9 xs *tag_dir = xs_fmt("%s/%c%c", g_tag_dir, md5_tag[0], md5_tag[1]);
10@@ -2247,7 +2247,7 @@ xs_str *tag_fn(const char *tag)
11 if (*tag == '#')
12 tag++;
13
14- xs *lw_tag = xs_tolower_i(xs_dup(tag));
15+ xs *lw_tag = xs_utf8_to_lower(xs_dup(tag));
16 xs *md5 = xs_md5_hex(lw_tag, strlen(lw_tag));
17
18 return xs_fmt("%s/tag/%c%c/%s.idx", srv_basedir, md5[0], md5[1], md5);
19@@ -2834,7 +2834,7 @@ int content_match(const char *file, const xs_dict *msg)
20 /* massage content (strip HTML tags, etc.) */
21 xs *c = xs_regex_replace(v, "<[^>]+>", " ");
22 c = xs_regex_replace_i(c, " {2,}", " ");
23- c = xs_tolower_i(c);
24+ c = xs_utf8_to_lower(c);
25
26 while (!r && !feof(f)) {
27 xs *rx = xs_strip_i(xs_readline(f));
M
format.c
+2,
-1
1@@ -8,6 +8,7 @@
2 #include "xs_json.h"
3 #include "xs_time.h"
4 #include "xs_match.h"
5+#include "xs_unicode.h"
6
7 #include "snac.h"
8
9@@ -443,7 +444,7 @@ xs_str *sanitize(const char *content)
10 if (n & 0x1) {
11 xs *s1 = xs_strip_i(xs_crop_i(xs_dup(v), v[1] == '/' ? 2 : 1, -1));
12 xs *l1 = xs_split_n(s1, " ", 1);
13- xs *tag = xs_tolower_i(xs_dup(xs_list_get(l1, 0)));
14+ xs *tag = xs_utf8_to_lower(xs_dup(xs_list_get(l1, 0)));
15 xs *s2 = NULL;
16 int i;
17
+7,
-6
1@@ -15,6 +15,7 @@
2 #include "xs_url.h"
3 #include "xs_mime.h"
4 #include "xs_match.h"
5+#include "xs_unicode.h"
6
7 #include "snac.h"
8
9@@ -381,7 +382,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path,
10 }
11 }
12
13- /* no code?
14+ /* no code?
15 I'm not sure of the impacts of this right now, but Subway Tooter does not
16 provide a code so one must be generated */
17 if (xs_is_null(code)){
18@@ -1637,7 +1638,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
19 const char *aq = xs_dict_get(args, "q");
20
21 if (!xs_is_null(aq)) {
22- xs *q = xs_tolower_i(xs_dup(aq));
23+ xs *q = xs_utf8_to_lower(xs_dup(aq));
24 out = xs_list_new();
25 xs *wing = following_list(&snac1);
26 xs *wers = follower_list(&snac1);
27@@ -1780,7 +1781,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
28 }
29 else
30 if (strcmp(opt, "statuses") == 0) {
31- /* we don't serve statuses of others; return the empty list */
32+ /* we don't serve statuses of others; return the empty list */
33 out = xs_list_new();
34 }
35 else
36@@ -1999,7 +2000,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
37 }
38 else
39 if (strcmp(cmd, "/v2/filters") == 0) { /** **/
40- /* snac will never have filters
41+ /* snac will never have filters
42 * but still, without a v2 endpoint a short delay is introduced
43 * in some apps */
44 *body = xs_dup("[]");
45@@ -2459,7 +2460,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
46 if (logged_in) {
47 const xs_list *timeline = xs_dict_get(args, "timeline[]");
48 xs_str *json = NULL;
49- if (!xs_is_null(timeline))
50+ if (!xs_is_null(timeline))
51 json = xs_json_dumps(markers_get(&snac1, timeline), 4);
52
53 if (!xs_is_null(json))
54@@ -3227,7 +3228,7 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
55 if (!xs_is_null(home))
56 home_marker = xs_dict_get(home, "last_read_id");
57 }
58-
59+
60 const xs_str *notify_marker = xs_dict_get(args, "notifications[last_read_id]");
61 if (xs_is_null(notify_marker)) {
62 const xs_dict *notify = xs_dict_get(args, "notifications");