PluginProbe
ActivityPub / 8.0.2
ActivityPub v8.0.2
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
← All changes | includes/handler/class-announce.php +9 -39 9.2.08.0.2 View file →
@@ -52,31 +52,15 @@
52 52 }
53 53
54 54 self::maybe_save_announce( $announcement, $user_ids );
55 55
56 - $object_url = object_to_uri( $announcement['object'] );
56 + if ( is_string( $announcement['object'] ) ) {
57 + $object = Http::get_remote_object( $announcement['object'] );
58 + } else {
59 + $object = $announcement['object'];
60 + }
57 61
58 - // Force no redirects for this object's request only, so the requested host stays the authoritative origin.
59 - $no_redirects = static function ( $args, $url ) use ( $object_url ) {
60 - if ( $url === $object_url ) {
61 - $args['redirection'] = 0;
62 - }
63 - return $args;
64 - };
65 -
66 - /*
67 - * Fetch the activity from its own id rather than the inline copy the Announce
68 - * carries: that copy is the announcer's, who is not necessarily the activity's
69 - * author. Redirects are forbidden (above) and the cache is bypassed so the
70 - * requested host is the authoritative origin — otherwise a redirect, or a
71 - * response cached from an earlier redirect-following fetch, could resolve to
72 - * attacker content while the host check below still saw the trusted host.
73 - */
74 - \add_filter( 'http_request_args', $no_redirects, 10, 2 );
75 - $object = Http::get_remote_object( $object_url, false );
76 - \remove_filter( 'http_request_args', $no_redirects, 10 );
77 -
78 - if ( ! $object || \is_wp_error( $object ) || ! \is_array( $object ) ) {
62 + if ( ! $object || is_wp_error( $object ) ) {
79 63 return;
80 64 }
81 65
82 66 if ( ! is_activity( $object ) ) {
@@ -82,21 +66,8 @@
82 66 if ( ! is_activity( $object ) ) {
83 67 return;
84 68 }
85 69
86 - $origin_host = \strtolower( (string) \wp_parse_url( (string) $object_url, \PHP_URL_HOST ) );
87 - $actor_host = \strtolower( (string) \wp_parse_url( (string) object_to_uri( $object['actor'] ?? '' ), \PHP_URL_HOST ) );
88 -
89 - /*
90 - * Only an actor's own server may vouch for an activity attributed to it, so the
91 - * host it was fetched from must equal its actor's host — the same key-host ==
92 - * actor-host binding verify_key_id() enforces for signed requests, generalised
93 - * to every relayed activity type.
94 - */
95 - if ( '' === $origin_host || '' === $actor_host || $origin_host !== $actor_host ) {
96 - return;
97 - }
98 -
99 70 $type = \strtolower( $object['type'] );
100 71
101 72 /**
102 73 * Fires after an Announce has been received.
@@ -130,10 +101,9 @@
130 101 if ( empty( $url ) ) {
131 102 return;
132 103 }
133 104
134 - // Match any status, so a repost that was marked as spam or trashed still counts as seen.
135 - $exists = Comment::object_id_to_comment( \esc_url_raw( $url ), array( 'status' => 'any' ) );
105 + $exists = Comment::object_id_to_comment( esc_url_raw( $url ) );
136 106 if ( $exists ) {
137 107 return;
138 108 }
139 109
@@ -144,11 +114,11 @@
144 114
145 115 $success = false;
146 116 $result = Interactions::add_reaction( $activity );
147 117
148 - if ( $result && ! \is_wp_error( $result ) ) {
118 + if ( $result && ! is_wp_error( $result ) ) {
149 119 $success = true;
150 - $result = \get_comment( $result );
120 + $result = get_comment( $result );
151 121 }
152 122
153 123 /**
154 124 * Fires after an ActivityPub Announce activity has been handled.