From 253e7f9eaa3f3279f2a8639949f74acf0797de33 Mon Sep 17 00:00:00 2001 From: default Date: Fri, 13 Oct 2023 06:33:12 +0200 Subject: Don't allow creating users which user name strings only differ in case. --- webfinger.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'webfinger.c') diff --git a/webfinger.c b/webfinger.c index 46867e9..13a6e6c 100644 --- a/webfinger.c +++ b/webfinger.c @@ -4,6 +4,7 @@ #include "xs.h" #include "xs_json.h" #include "xs_curl.h" +#include "xs_mime.h" #include "snac.h" @@ -128,20 +129,11 @@ int webfinger_get_handler(xs_dict *req, char *q_path, if (xs_startswith(resource, "https:/" "/")) { /* actor search: find a user with this actor */ - xs *list = user_list(); - char *p, *uid; - - p = list; - while (xs_list_iter(&p, &uid)) { - if (user_open(&snac, uid)) { - if (strcmp(snac.actor, resource) == 0) { - found = 1; - break; - } + xs *l = xs_split(resource, "/"); + char *uid = xs_list_get(l, -1); - user_free(&snac); - } - } + if (uid) + found = user_open(&snac, uid); } else if (xs_startswith(resource, "acct:")) { @@ -180,6 +172,17 @@ int webfinger_get_handler(xs_dict *req, char *q_path, links = xs_list_append(links, aaj); + char *avatar = xs_dict_get(snac.config, "avatar"); + if (!xs_is_null(avatar) && *avatar) { + xs *d = xs_dict_new(); + + d = xs_dict_append(d, "rel", "http:/" "/webfinger.net/rel/avatar"); + d = xs_dict_append(d, "type", xs_mime_by_ext(avatar)); + d = xs_dict_append(d, "href", avatar); + + links = xs_list_append(links, d); + } + obj = xs_dict_append(obj, "subject", acct); obj = xs_dict_append(obj, "links", links); -- cgit v1.2.3