From 4287f14bc530008a2a03b6ead6a7f81c15d9864d Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 6 Apr 2022 01:03:05 -0600 Subject: [PATCH] Update InboxPipeline, fixes #3332 --- app/Jobs/InboxPipeline/InboxValidator.php | 5 ++--- app/Jobs/InboxPipeline/InboxWorker.php | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/Jobs/InboxPipeline/InboxValidator.php b/app/Jobs/InboxPipeline/InboxValidator.php index 4fc1b75a2..481844bb2 100644 --- a/app/Jobs/InboxPipeline/InboxValidator.php +++ b/app/Jobs/InboxPipeline/InboxValidator.php @@ -167,9 +167,8 @@ class InboxValidator implements ShouldQueue && is_array($bodyDecoded['object']) && isset($bodyDecoded['object']['attributedTo']) ) { - if(parse_url($bodyDecoded['object']['attributedTo'], PHP_URL_HOST) !== $keyDomain) { + if(parse_url(Helpers::pluckval($bodyDecoded['object']['attributedTo']), PHP_URL_HOST) !== $keyDomain) { return; - abort(400, 'Invalid request'); } } if(!$keyDomain || !$idDomain || $keyDomain !== $idDomain) { @@ -178,7 +177,7 @@ class InboxValidator implements ShouldQueue } $actor = Profile::whereKeyId($keyId)->first(); if(!$actor) { - $actorUrl = is_array($bodyDecoded['actor']) ? $bodyDecoded['actor'][0] : $bodyDecoded['actor']; + $actorUrl = Helpers::pluckval($bodyDecoded['actor']); $actor = Helpers::profileFirstOrNew($actorUrl); } if(!$actor) { diff --git a/app/Jobs/InboxPipeline/InboxWorker.php b/app/Jobs/InboxPipeline/InboxWorker.php index 44e3a1cb0..f475b2dc5 100644 --- a/app/Jobs/InboxPipeline/InboxWorker.php +++ b/app/Jobs/InboxPipeline/InboxWorker.php @@ -157,7 +157,7 @@ class InboxWorker implements ShouldQueue && is_array($bodyDecoded['object']) && isset($bodyDecoded['object']['attributedTo']) ) { - if(parse_url($bodyDecoded['object']['attributedTo'], PHP_URL_HOST) !== $keyDomain) { + if(parse_url(Helpers::pluckval($bodyDecoded['object']['attributedTo']), PHP_URL_HOST) !== $keyDomain) { return; } } @@ -166,7 +166,7 @@ class InboxWorker implements ShouldQueue } $actor = Profile::whereKeyId($keyId)->first(); if(!$actor) { - $actorUrl = is_array($bodyDecoded['actor']) ? $bodyDecoded['actor'][0] : $bodyDecoded['actor']; + $actorUrl = Helpers::pluckval($bodyDecoded['actor']); $actor = Helpers::profileFirstOrNew($actorUrl); } if(!$actor) {