Browse Source

Webfinger: if the 'subject' is not an acct:, search in 'aliases'.

Implementations like Hubzilla return a subject that is an http: instead of an acct:,
but have one in the 'aliases' array, so use it.
grunfink 3 months ago
parent
commit
45d7d893a2
1 changed files with 16 additions and 0 deletions
  1. 16 0
      webfinger.c

+ 16 - 0
webfinger.c

@@ -96,6 +96,22 @@ int webfinger_request_signed(snac *snac, const char *qs, xs_str **actor, xs_str
 
             if (subject && xs_startswith(subject, "acct:"))
                 *user = xs_replace_n(subject, "acct:", "", 1);
+            else {
+                /* subject not an 'acct:': try in the aliases
+                   (i.e. hubzilla does this) */
+                const char *aliases = xs_dict_get(obj, "aliases");
+
+                if (xs_is_list(aliases)) {
+                    const char *v;
+
+                    xs_list_foreach(aliases, v) {
+                        if (xs_startswith(v, "acct:")) {
+                            *user = xs_replace_n(v, "acct:", "", 1);
+                            break;
+                        }
+                    }
+                }
+            }
         }
 
         if (actor != NULL) {