From 35b0a9e3aea61a51b48c261c9b28f2cb2a64826d Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Sun, 16 Apr 2017 11:01:16 +0200 Subject: [PATCH] Handle normalized acct: URIs in ostatussub Mastodon sent the proper acct: URI and not just 'user@domain' when using the remote subscribe functionality. --- plugins/OStatus/actions/ostatussub.php | 4 ++-- plugins/OStatus/classes/Ostatus_profile.php | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/OStatus/actions/ostatussub.php b/plugins/OStatus/actions/ostatussub.php index 75c75c54c6..a8039ae565 100644 --- a/plugins/OStatus/actions/ostatussub.php +++ b/plugins/OStatus/actions/ostatussub.php @@ -242,9 +242,9 @@ class OStatusSubAction extends Action function pullRemoteProfile() { $validate = new Validate(); - $this->profile_uri = $this->trimmed('profile'); + $this->profile_uri = Discovery::normalize($this->trimmed('profile')); try { - if ($validate->email($this->profile_uri)) { + if (Discovery::isAcct($this->profile_uri) && $validate->email(mb_substr($this->profile_uri, 5))) { $this->oprofile = Ostatus_profile::ensureWebfinger($this->profile_uri); } else if ($validate->uri($this->profile_uri)) { $this->oprofile = Ostatus_profile::ensureProfileURL($this->profile_uri); diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index 2724aaedc0..eb385e09f1 100644 --- a/plugins/OStatus/classes/Ostatus_profile.php +++ b/plugins/OStatus/classes/Ostatus_profile.php @@ -1574,8 +1574,10 @@ class Ostatus_profile extends Managed_DataObject */ public static function ensureWebfinger($addr) { - // First, try the cache + // Normalize $addr, i.e. add 'acct:' if missing + $addr = Discovery::normalize($addr); + // Try the cache $uri = self::cacheGet(sprintf('ostatus_profile:webfinger:%s', $addr)); if ($uri !== false) { @@ -1591,7 +1593,7 @@ class Ostatus_profile extends Managed_DataObject } // Try looking it up - $oprofile = Ostatus_profile::getKV('uri', Discovery::normalize($addr)); + $oprofile = Ostatus_profile::getKV('uri', $addr); if ($oprofile instanceof Ostatus_profile) { self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->getUri());