diff options
Diffstat (limited to 'internal/api/s2s/webfinger/webfingerget.go')
-rw-r--r-- | internal/api/s2s/webfinger/webfingerget.go | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/internal/api/s2s/webfinger/webfingerget.go b/internal/api/s2s/webfinger/webfingerget.go index ee3176413..01e5e8e8a 100644 --- a/internal/api/s2s/webfinger/webfingerget.go +++ b/internal/api/s2s/webfinger/webfingerget.go @@ -43,19 +43,21 @@ func (m *Module) WebfingerGETRequest(c *gin.Context) { return } - withAcct := strings.Split(q, "acct:") - if len(withAcct) != 2 { - l.Debugf("aborting request because resource query %s could not be split by 'acct:'", q) - c.JSON(http.StatusBadRequest, gin.H{"error": "bad request"}) - return - } + // remove the acct: prefix if it's present + trimAcct := strings.TrimPrefix(q, "acct:") + // remove the first @ in @whatever@example.org if it's present + namestring := strings.TrimPrefix(trimAcct, "@") - usernameAndAccountDomain := strings.Split(withAcct[1], "@") + // at this point we should have a string like some_user@example.org + l.Debugf("got finger request for '%s'", namestring) + + usernameAndAccountDomain := strings.Split(namestring, "@") if len(usernameAndAccountDomain) != 2 { - l.Debugf("aborting request because username and domain could not be parsed from %s", withAcct[1]) + l.Debugf("aborting request because username and domain could not be parsed from %s", namestring) c.JSON(http.StatusBadRequest, gin.H{"error": "bad request"}) return } + username := strings.ToLower(usernameAndAccountDomain[0]) accountDomain := strings.ToLower(usernameAndAccountDomain[1]) if username == "" || accountDomain == "" { @@ -77,7 +79,7 @@ func (m *Module) WebfingerGETRequest(c *gin.Context) { ctx = context.WithValue(ctx, util.APRequestingPublicKeyVerifier, verifier) } - resp, err := m.processor.GetWebfingerAccount(ctx, username, c.Request.URL) + resp, err := m.processor.GetWebfingerAccount(ctx, username) if err != nil { l.Debugf("aborting request with an error: %s", err.Error()) c.JSON(err.Code(), gin.H{"error": err.Safe()}) |