commit 24105f6

postscriptum  ·  2025-05-22 00:34:48 +0000 UTC
parent 072ae21
use utf-8 lowercase function for tags #396
3 files changed,  +5, -4
M data.c
+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
+2, -2
 1@@ -2200,7 +2200,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@@ -2230,7 +2230,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);
+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