diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2018-11-19 11:10:24 -0100 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2018-11-19 11:10:24 -0100 |
commit | 31b729f5d4224a6401cb9ff9bab5836cf0b3c765 (patch) | |
tree | 821a60c0e225fac83378c89167cc042bf2b178a4 /lib/Model/ActivityPub/ACore.php | |
parent | 596669104e13fd1057120efe95ebbfe460e697ae (diff) |
fixing verification on source
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib/Model/ActivityPub/ACore.php')
-rw-r--r-- | lib/Model/ActivityPub/ACore.php | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/lib/Model/ActivityPub/ACore.php b/lib/Model/ActivityPub/ACore.php index 9fc4ee80..64f59360 100644 --- a/lib/Model/ActivityPub/ACore.php +++ b/lib/Model/ActivityPub/ACore.php @@ -32,6 +32,7 @@ namespace OCA\Social\Model\ActivityPub; use daita\MySmallPhpTools\Traits\TArrayTools; use JsonSerializable; +use OCA\Social\Exceptions\ActivityCantBeVerifiedException; use OCA\Social\Model\InstancePath; use OCA\Social\Service\ICoreService; @@ -184,20 +185,23 @@ abstract class ACore implements JsonSerializable { /** * @param string $url * - * @return bool + * @throws ActivityCantBeVerifiedException */ - public function verify(string $url): bool { - if (parse_url($this->getId(), PHP_URL_HOST) !== - parse_url($url, PHP_URL_HOST)) - return false; + public function verify(string $url) { + $url1 = parse_url($this->getId()); + $url2 = parse_url($url); - \OC::$server->getLogger()->log(2, '#### ' . json_encode(parse_url($this->getId(), PHP_URL_PORT))); -// if (parse_url($this->getId(), PHP_URL_PORT) !== -// parse_url($url, PHP_URL_HOST)) -// return false; -// + if ($this->get('host', $url1, '1') !== $this->get('host', $url2, '2')) { + throw new ActivityCantBeVerifiedException('activity cannot be verified'); + } - return true; + if ($this->get('scheme', $url1, '1') !== $this->get('scheme', $url2, '2')) { + throw new ActivityCantBeVerifiedException('activity cannot be verified'); + } + + if ($this->getInt('port', $url1, 1) !== $this->getInt('port', $url2, 1)) { + throw new ActivityCantBeVerifiedException('activity cannot be verified'); + } } |