diff --git a/src/Entity/Actor.php b/src/Entity/Actor.php index bc7a693377..103e33fb2f 100644 --- a/src/Entity/Actor.php +++ b/src/Entity/Actor.php @@ -323,16 +323,17 @@ class Actor extends Entity { // Will throw exception on invalid input. $nickname = Nickname::normalize($nickname, check_already_used: false); - return Cache::get( - 'relative-nickname-' . $nickname . '-' . $this->getId(), - fn () => DB::dql( - 'select a from actor a where ' - . 'a.id in (select followed from follow f join actor a on f.followed = a.id where and f.follower = :actor_id and a.nickname = :nickname) or' - . 'a.id in (select follower from follow f join actor a on f.follower = a.id where and f.followed = :actor_id and a.nickname = :nickname) or' - . 'a.nickname = :nickname' - . 'limit 1', - ['nickname' => $nickname, 'actor_id' => $this->getId()], - ), + return Cache::get('relative-nickname-' . $nickname . '-' . $this->getId(), + fn () => DB::dql(<< $nickname, 'actor_id' => $this->getId()], + ['limit' => 1] + )[0] ?? null ); } diff --git a/src/Util/Common.php b/src/Util/Common.php index aa3ee0bce5..8a8cdd8619 100644 --- a/src/Util/Common.php +++ b/src/Util/Common.php @@ -289,7 +289,7 @@ abstract class Common // (if false, we use '?' in 'https?' to say the 's' is optional) $regex = $ensure_secure ? '/^https$/' : '/^https?$/'; - return filter_var($url, \FILTER_VALIDATE_URL) + return filter_var($url, \FILTER_VALIDATE_URL) !== false && preg_match($regex, parse_url($url, \PHP_URL_SCHEME)); } diff --git a/src/Util/Formatting.php b/src/Util/Formatting.php index 7ce3c4b813..da2e6a0937 100644 --- a/src/Util/Formatting.php +++ b/src/Util/Formatting.php @@ -307,10 +307,11 @@ abstract class Formatting $matches = self::findMentionsRaw($text, '@'); + //dd($matches); foreach ($matches as $match) { try { $nickname = Nickname::normalize($match[0], check_already_used: false); - } catch (NicknameException $e) { + } catch (NicknameException) { // Bogus match? Drop it. continue; } @@ -388,7 +389,7 @@ abstract class Formatting $group_matches = self::findMentionsRaw($text, '!'); foreach ($group_matches as $group_match) { - $nickname = Nickname::normalize($group_match[0], check_already_used: false); + $nickname = Nickname::normalize($group_match[0], check_already_used: false, check_is_allowed: false); $group = Group::getFromNickname($nickname, $actor); if (!$group instanceof Group) { @@ -410,7 +411,7 @@ abstract class Formatting Event::handle('EndFindMentions', [$actor, $text, &$mentions]); } - + //dd($text,$mentions); return $mentions; } @@ -440,6 +441,7 @@ abstract class Formatting $atmatches, \PREG_OFFSET_CAPTURE, ); + //dd('/' . Nickname::BEFORE_MENTIONS . preg_quote($preMention, '/') . '(' . Nickname::DISPLAY_FMT . ')\b(?!\@)/', $atmatches); return array_merge($tmatches[1], $atmatches[1]); } diff --git a/src/Util/Nickname.php b/src/Util/Nickname.php index b46b53164c..70748b67dd 100644 --- a/src/Util/Nickname.php +++ b/src/Util/Nickname.php @@ -120,7 +120,7 @@ class Nickname * FIXME: Make this so you can have multiple whitespace but not multiple * parenthesis or something. '(((@n_n@)))' might as well be a smiley. */ - public const BEFORE_MENTIONS = '(?:^|[\s\.\,\:\;\[\(]+)'; + public const BEFORE_MENTIONS = '(?:^|[\s\.\,\:\;\[\(\>]+)'; public const CHECK_LOCAL_USER = 1; public const CHECK_LOCAL_GROUP = 2;