Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(settings): change Mastodon only URI to webfinger
Signed-off-by: 諏訪子 <[email protected]>
  • Loading branch information
TechnicalSuwako authored and backportbot[bot] committed Jul 7, 2025
commit 8f0f6e6aacd0c373ad8109c2136fae3b92f6049d
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@
- szaimen <[email protected]>
- tbartenstein <[email protected]>
- tbelau666 <[email protected]>
- TechnicalSuwako <[email protected]>
- tgrant <[email protected]>
- timm2k <[email protected]>
- tux-rampage <[email protected]>
Expand Down
4 changes: 2 additions & 2 deletions lib/private/Accounts/AccountManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ private function sanitizePropertyFediverse(IAccountProperty $property): void {

try {
// try the public account lookup API of mastodon
$response = $client->get("https://{$instance}/api/v1/accounts/lookup?acct={$username}@{$instance}");
$response = $client->get("https://{$instance}/.well-known/webfinger?resource=acct:{$username}@{$instance}");
// should be a json response with account information
$data = $response->getBody();
if (is_resource($data)) {
Expand All @@ -745,7 +745,7 @@ private function sanitizePropertyFediverse(IAccountProperty $property): void {
$decoded = json_decode($data, true);
// ensure the username is the same the user passed
// in this case we can assume this is a valid fediverse server and account
if (!is_array($decoded) || ($decoded['username'] ?? '') !== $username) {
if (!is_array($decoded) || ($decoded['subject'] ?? '') !== "acct:{$username}@{$instance}") {
throw new InvalidArgumentException();
}
} catch (InvalidArgumentException) {
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/Accounts/AccountManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -839,12 +839,12 @@ public function testSanitizingFediverseServer(string $input, ?string $output, bo
->willReturn($serverResponse);
$client->expects(self::once())
->method('get')
->with('https://example.com/api/v1/accounts/lookup?acct=[email protected]')
->with('https://example.com/.well-known/webfinger?resource=acct:[email protected]')
->willReturn($response);
} else {
$client->expects(self::once())
->method('get')
->with('https://example.com/api/v1/accounts/lookup?acct=[email protected]')
->with('https://example.com/.well-known/webfinger?resource=acct:[email protected]')
->willThrowException(new \Exception('404'));
}

Expand Down