updated plugin ActivityPub
version 0.13.4
This commit is contained in:
@ -22,7 +22,9 @@ class Webfinger {
|
||||
*/
|
||||
public static function register_routes() {
|
||||
\register_rest_route(
|
||||
'activitypub/1.0', '/webfinger', array(
|
||||
'activitypub/1.0',
|
||||
'/webfinger',
|
||||
array(
|
||||
array(
|
||||
'methods' => \WP_REST_Server::READABLE,
|
||||
'callback' => array( '\Activitypub\Rest\Webfinger', 'webfinger' ),
|
||||
@ -42,15 +44,16 @@ class Webfinger {
|
||||
public static function webfinger( $request ) {
|
||||
$resource = $request->get_param( 'resource' );
|
||||
|
||||
$matches = array();
|
||||
$matched = \preg_match( '/^acct:([^@]+)@(.+)$/', $resource, $matches );
|
||||
$matched = \str_contains( $resource, '@' );
|
||||
|
||||
if ( ! $matched ) {
|
||||
return new \WP_Error( 'activitypub_unsupported_resource', \__( 'Resource is invalid', 'activitypub' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$resource_identifier = $matches[1];
|
||||
$resource_host = $matches[2];
|
||||
$resource = \str_replace( 'acct:', '', $resource );
|
||||
|
||||
$resource_identifier = \substr( $resource, 0, \strrpos( $resource, '@' ) );
|
||||
$resource_host = \substr( \strrchr( $resource, '@' ), 1 );
|
||||
|
||||
if ( \wp_parse_url( \home_url( '/' ), \PHP_URL_HOST ) !== $resource_host ) {
|
||||
return new \WP_Error( 'activitypub_wrong_host', \__( 'Resource host does not match blog host', 'activitypub' ), array( 'status' => 404 ) );
|
||||
@ -95,7 +98,7 @@ class Webfinger {
|
||||
$params['resource'] = array(
|
||||
'required' => true,
|
||||
'type' => 'string',
|
||||
'pattern' => '^acct:([^@]+)@(.+)$',
|
||||
'pattern' => '^acct:(.+)@(.+)$',
|
||||
);
|
||||
|
||||
return $params;
|
||||
|
Reference in New Issue
Block a user