From b36d665cff5c96f3d89bb6b9a5c93db483808613 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Fri, 20 May 2022 08:48:40 +0200 Subject: [PATCH 1/2] fix docker --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index c7d6b30..400fbdf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,5 +22,6 @@ services: restart: always environment: WORDPRESS_DB_HOST: db:3306 + WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress WORDPRESS_DEBUG: 1 From b3aefc62dbcaa10027f257ce260b4b4a6fac9091 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Fri, 20 May 2022 08:49:05 +0200 Subject: [PATCH 2/2] fix webfinger for email identifiers fix #152 --- includes/rest/class-webfinger.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/includes/rest/class-webfinger.php b/includes/rest/class-webfinger.php index 5684d09..60eb5d2 100644 --- a/includes/rest/class-webfinger.php +++ b/includes/rest/class-webfinger.php @@ -44,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 ) ); @@ -97,7 +98,7 @@ class Webfinger { $params['resource'] = array( 'required' => true, 'type' => 'string', - 'pattern' => '^acct:([^@]+)@(.+)$', + 'pattern' => '^acct:(.+)@(.+)$', ); return $params;