Skip to content

Commit e382749

Browse files
authored
Following: Check remote URLs/Objects for Actor type (#2041)
1 parent 7f6805c commit e382749

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fixed
3+
4+
More reliable Actor checks during the follow process.

includes/collection/class-actors.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
use Activitypub\Activity\Actor;
1515

1616
use function Activitypub\get_remote_metadata_by_actor;
17-
use function Activitypub\object_to_uri;
18-
use function Activitypub\normalize_url;
17+
use function Activitypub\is_actor;
18+
use function Activitypub\is_user_type_disabled;
1919
use function Activitypub\normalize_host;
20+
use function Activitypub\normalize_url;
21+
use function Activitypub\object_to_uri;
2022
use function Activitypub\url_to_authorid;
21-
use function Activitypub\is_user_type_disabled;
2223
use function Activitypub\user_can_activitypub;
2324

2425
/**
@@ -561,6 +562,14 @@ public static function fetch_remote_by_uri( $actor_uri ) {
561562
return $object;
562563
}
563564

565+
if ( ! is_actor( $object ) ) {
566+
return new \WP_Error(
567+
'activitypub_no_actor',
568+
\__( 'Object is not an Actor', 'activitypub' ),
569+
array( 'status' => 400 )
570+
);
571+
}
572+
564573
$post_id = self::upsert( $object );
565574

566575
if ( \is_wp_error( $post_id ) ) {

tests/includes/class-test-scheduler.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ public function test_cleanup_remote_actors() {
459459
'activitypub_pre_http_get_remote_object',
460460
function () {
461461
return array(
462+
'type' => 'Person',
462463
'name' => 'Test User',
463464
'preferredUsername' => 'test',
464465
'id' => 'https://example.com/users/test',

0 commit comments

Comments
 (0)