Merge pull request #153 from pfefferle/fix-webfinger
This commit is contained in:
commit
c63de35e3f
2 changed files with 7 additions and 5 deletions
|
@ -22,5 +22,6 @@ services:
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
WORDPRESS_DB_HOST: db:3306
|
WORDPRESS_DB_HOST: db:3306
|
||||||
|
WORDPRESS_DB_USER: wordpress
|
||||||
WORDPRESS_DB_PASSWORD: wordpress
|
WORDPRESS_DB_PASSWORD: wordpress
|
||||||
WORDPRESS_DEBUG: 1
|
WORDPRESS_DEBUG: 1
|
||||||
|
|
|
@ -44,15 +44,16 @@ class Webfinger {
|
||||||
public static function webfinger( $request ) {
|
public static function webfinger( $request ) {
|
||||||
$resource = $request->get_param( 'resource' );
|
$resource = $request->get_param( 'resource' );
|
||||||
|
|
||||||
$matches = array();
|
$matched = \str_contains( $resource, '@' );
|
||||||
$matched = \preg_match( '/^acct:([^@]+)@(.+)$/', $resource, $matches );
|
|
||||||
|
|
||||||
if ( ! $matched ) {
|
if ( ! $matched ) {
|
||||||
return new \WP_Error( 'activitypub_unsupported_resource', \__( 'Resource is invalid', 'activitypub' ), array( 'status' => 400 ) );
|
return new \WP_Error( 'activitypub_unsupported_resource', \__( 'Resource is invalid', 'activitypub' ), array( 'status' => 400 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
$resource_identifier = $matches[1];
|
$resource = \str_replace( 'acct:', '', $resource );
|
||||||
$resource_host = $matches[2];
|
|
||||||
|
$resource_identifier = \substr( $resource, 0, \strrpos( $resource, '@' ) );
|
||||||
|
$resource_host = \substr( \strrchr( $resource, '@' ), 1 );
|
||||||
|
|
||||||
if ( \wp_parse_url( \home_url( '/' ), \PHP_URL_HOST ) !== $resource_host ) {
|
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 ) );
|
return new \WP_Error( 'activitypub_wrong_host', \__( 'Resource host does not match blog host', 'activitypub' ), array( 'status' => 404 ) );
|
||||||
|
@ -97,7 +98,7 @@ class Webfinger {
|
||||||
$params['resource'] = array(
|
$params['resource'] = array(
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'pattern' => '^acct:([^@]+)@(.+)$',
|
'pattern' => '^acct:(.+)@(.+)$',
|
||||||
);
|
);
|
||||||
|
|
||||||
return $params;
|
return $params;
|
||||||
|
|
Loading…
Reference in a new issue