diff --git a/activitypub.php b/activitypub.php index f50a4a916..c23e5eb30 100644 --- a/activitypub.php +++ b/activitypub.php @@ -29,7 +29,7 @@ \defined( 'ACTIVITYPUB_SHOW_PLUGIN_RECOMMENDATIONS' ) || \define( 'ACTIVITYPUB_SHOW_PLUGIN_RECOMMENDATIONS', true ); \defined( 'ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS' ) || \define( 'ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS', 3 ); \defined( 'ACTIVITYPUB_HASHTAGS_REGEXP' ) || \define( 'ACTIVITYPUB_HASHTAGS_REGEXP', '(?:(?<=\s)|(?<=

)|(?<=
)|^)#([A-Za-z0-9_]+)(?:(?=\s|[[:punct:]]|$))' ); -\defined( 'ACTIVITYPUB_USERNAME_REGEXP' ) || \define( 'ACTIVITYPUB_USERNAME_REGEXP', '(?:([A-Za-z0-9_-]+)@((?:[A-Za-z0-9_-]+\.)+[A-Za-z]+))' ); +\defined( 'ACTIVITYPUB_USERNAME_REGEXP' ) || \define( 'ACTIVITYPUB_USERNAME_REGEXP', '(?:([A-Za-z0-9\._-]+)@((?:[A-Za-z0-9_-]+\.)+[A-Za-z]+))' ); \defined( 'ACTIVITYPUB_CUSTOM_POST_CONTENT' ) || \define( 'ACTIVITYPUB_CUSTOM_POST_CONTENT', "[ap_title]\n\n[ap_content]\n\n[ap_hashtags]\n\n[ap_shortlink]" ); \defined( 'ACTIVITYPUB_AUTHORIZED_FETCH' ) || \define( 'ACTIVITYPUB_AUTHORIZED_FETCH', false ); \defined( 'ACTIVITYPUB_DISABLE_REWRITES' ) || \define( 'ACTIVITYPUB_DISABLE_REWRITES', false ); diff --git a/includes/class-mention.php b/includes/class-mention.php index 01bbeaf47..0b8c0b5e5 100644 --- a/includes/class-mention.php +++ b/includes/class-mention.php @@ -101,7 +101,14 @@ public static function replace_with_links( $result ) { if ( ! empty( $metadata['preferredUsername'] ) ) { $username = $metadata['preferredUsername']; } - return \sprintf( '@%s', esc_url( $metadata['url'] ), esc_html( $username ) ); + + $url = isset( $metadata['url'] ) ? $metadata['url'] : $metadata['url']; + + if ( \is_array( $url ) ) { + $url = $url[0]; + } + + return \sprintf( '@%s', esc_url( $url ), esc_html( $username ) ); } return $result[0];