diff --git a/components/Language/Language.php b/components/Language/Language.php index c50be9c701..e91821bba6 100644 --- a/components/Language/Language.php +++ b/components/Language/Language.php @@ -90,13 +90,13 @@ class Language extends Component $note_expr = $temp_note_expr; $actor_expr = $temp_actor_expr; return Event::stop; - } elseif (Formatting::startsWith($term, GSF::cartesianProduct(['-', '_'], ['note', 'post'], ['lang', 'language'], [':']))) { + } elseif (Formatting::startsWith($term, GSF::cartesianProduct([['note', 'post'], ['lang', 'language'], [':']], separator: ['-', '_']))) { $note_expr = $temp_note_expr; return Event::stop; - } elseif (Formatting::startsWith($term, GSF::cartesianProduct(['-', '_'], ['note', 'post'], ['author', 'actor', 'people', 'person'], ['lang', 'language'], [':']))) { + } elseif (Formatting::startsWith($term, GSF::cartesianProduct([['note', 'post'], ['author', 'actor', 'people', 'person'], ['lang', 'language'], [':']], separator: ['-', '_']))) { $note_expr = $temp_note_actor_expr; return Event::stop; - } elseif (Formatting::startsWith($term, GSF::cartesianProduct(['-', '_'], ['actor', 'people', 'person'], ['lang', 'language'], [':']))) { + } elseif (Formatting::startsWith($term, GSF::cartesianProduct([['actor', 'people', 'person'], ['lang', 'language'], [':']], separator: ['-', '_']))) { $actor_expr = $temp_actor_expr; return Event::stop; } diff --git a/components/Tag/Tag.php b/components/Tag/Tag.php index 51c5a87697..f82c7a09f0 100644 --- a/components/Tag/Tag.php +++ b/components/Tag/Tag.php @@ -39,6 +39,7 @@ use App\Util\Exception\ClientException; use App\Util\Formatting; use App\Util\Functional as GSF; use App\Util\HTML; +use App\Util\Nickname; use Component\Language\Entity\Language; use Component\Tag\Controller as C; use Doctrine\Common\Collections\ExpressionBuilder; @@ -47,7 +48,6 @@ use Doctrine\ORM\QueryBuilder; use Functional as F; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\HttpFoundation\Request; -use App\Util\Nickname; /** * Component responsible for extracting tags from posted notes, as well as normalizing them @@ -58,10 +58,10 @@ use App\Util\Nickname; */ class Tag extends Component { - public const MAX_TAG_LENGTH = 64; - public const TAG_REGEX = '/(^|\\s)(#[\\pL\\pN_\\-]{1,64})/u'; // Brion Vibber 2011-02-23 v2:classes/Notice.php:367 function saveTags - public const TAG_CIRCLE_REGEX = '/' . Nickname::BEFORE_MENTIONS . '@#([\pL\pN_\-\.]{1,64})/'; - public const TAG_SLUG_REGEX = '[A-Za-z0-9]{1,64}'; + public const MAX_TAG_LENGTH = 64; + public const TAG_REGEX = '/(^|\\s)(#[\\pL\\pN_\\-]{1,64})/u'; // Brion Vibber 2011-02-23 v2:classes/Notice.php:367 function saveTags + public const TAG_CIRCLE_REGEX = '/' . Nickname::BEFORE_MENTIONS . '@#([\pL\pN_\-\.]{1,64})/'; + public const TAG_SLUG_REGEX = '[A-Za-z0-9]{1,64}'; public function onAddRoute($r): bool { @@ -177,7 +177,7 @@ class Tag extends Component $note_expr = $temp_note_expr; } elseif (Formatting::startsWith($term, ['people:', 'actor:'])) { $actor_expr = $temp_actor_expr; - } elseif (Formatting::startsWith($term, GSF::cartesianProduct('-', ['people', 'actor'], ['circle:', 'list:']))) { + } elseif (Formatting::startsWith($term, GSF::cartesianProduct([['people', 'actor'], ['circle', 'list'], [':']], separator: ['-', '_']))) { $null_tagger_expr = $eb->isNull('actor_circle.tagger'); $tagger_expr = \is_null($actor_expr) ? $null_tagger_expr : $eb->orX($null_tagger_expr, $eb->eq('actor_circle.tagger', $actor->getId())); $tags = array_unique([$search_term, $canon_search_term]);