Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebFinger improvement #3167

Closed
rebelcode-xr opened this issue Jan 19, 2022 · 1 comment
Closed

WebFinger improvement #3167

rebelcode-xr opened this issue Jan 19, 2022 · 1 comment

Comments

@rebelcode-xr
Copy link

rebelcode-xr commented Jan 19, 2022

Right now the WebFinger lookup implementation assumes that "rel": "self" is in position 0 of the array links:

$profile = Helpers::profileFetch($webfinger['links'][0]['href']);
https://github.com/pixelfed/pixelfed/blob/dev/app/Services/WebfingerService.php

            if(isset($json['links']['href'])) {
                $href = $json['links']['href'];
            } else {
                $href = $json['links'][0]['href'];
            }

https://github.com/pixelfed/pixelfed/blob/dev/app/Services/NodeinfoService.php

This might lead to incompatibilities with other implementations.

I found this (sadly I forgot where 🙄) to be a better way:

$found_url = "";
foreach ($data['links'] as $link) {
	if (isset($link['rel'], $link['type'], $link['href'])) {
			if ($link['rel'] == 'self'
					&& $link['type'] == 'application/activity+json'
			) {
					$found_url = $link['href'];
			}
	}
}
@dansup dansup closed this as completed in aff7456 Jan 23, 2022
@rebelcode-xr
Copy link
Author

happy to help 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant