summaryrefslogtreecommitdiff
path: root/webfinger.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-10-13 06:33:12 +0200
committerdefault <nobody@localhost>2023-10-13 06:33:12 +0200
commit253e7f9eaa3f3279f2a8639949f74acf0797de33 (patch)
treebb7ff4868154bdad2325c27fdd0b4c55083dd5f4 /webfinger.c
parente127269a4a095c8628cef8e83c10588fd91666da (diff)
Don't allow creating users which user name strings only differ in case.
Diffstat (limited to 'webfinger.c')
-rw-r--r--webfinger.c29
1 files changed, 16 insertions, 13 deletions
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);