Skip to content
Open
Changes from all commits
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
13 changes: 11 additions & 2 deletions lib/WellKnown/WebfingerHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ public function handle(
*/
public function handleWebfinger(IRequestContext $context, ?IResponse $previousResponse): ?IResponse {
$subject = $this->getSubjectFromRequest($context->getHttpRequest());

// the `resource` parameter is required
if ($subject === '') {
return new JrdResponse('', Http::STATUS_BAD_REQUEST);
}

if (str_starts_with($subject, 'acct:')) {
$subject = substr($subject, 5);
}
Expand Down Expand Up @@ -216,8 +222,11 @@ private function getSubjectFromRequest(IRequest $request): string {

// work around to extract resource:
// on some setup (i.e. tests) the data are not available from IRequest
parse_str(parse_url($request->getRequestUri(), PHP_URL_QUERY), $query);

$requestUri = $request->getRequestUri();
if ($requestUri !== '') {
parse_str(parse_url($requestUri, PHP_URL_QUERY) ?? '', $query);
}
Comment on lines +225 to +228
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$requestUri = $request->getRequestUri();
if ($requestUri !== '') {
parse_str(parse_url($requestUri, PHP_URL_QUERY) ?? '', $query);
}
parse_str(parse_url($request->getRequestUri(), PHP_URL_QUERY) ?? '', $query);

The if is not useful anymore, I think


return $query['resource'] ?? '';
}
}
Loading