From 4b8c63121637778261f7aa19f6a2999c9dd99714 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 3 Oct 2022 13:53:19 +0000 Subject: [PATCH] Issue 11891: Enable search for user@domain.tld --- src/Module/BaseSearch.php | 4 ++-- src/Module/Contact.php | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Module/BaseSearch.php b/src/Module/BaseSearch.php index f1c9f451ec..276598131b 100644 --- a/src/Module/BaseSearch.php +++ b/src/Module/BaseSearch.php @@ -64,7 +64,7 @@ class BaseSearch extends BaseModule $header = ''; if (strpos($search, '@') === 0) { - $search = substr($search, 1); + $search = trim(substr($search, 1)); $type = Search::TYPE_PEOPLE; $header = DI::l10n()->t('People Search - %s', $search); @@ -74,7 +74,7 @@ class BaseSearch extends BaseModule } if (strpos($search, '!') === 0) { - $search = substr($search, 1); + $search = trim(substr($search, 1)); $type = Search::TYPE_FORUM; $header = DI::l10n()->t('Forum Search - %s', $search); } diff --git a/src/Module/Contact.php b/src/Module/Contact.php index 05c4e05081..9c073b3ef1 100644 --- a/src/Module/Contact.php +++ b/src/Module/Contact.php @@ -246,8 +246,10 @@ class Contact extends BaseModule if ($search) { $searching = true; $search_hdr = $search; - $search_txt = preg_quote($search); - $sql_extra .= " AND (name REGEXP ? OR url REGEXP ? OR nick REGEXP ?)"; + $search_txt = preg_quote(trim($search, ' @!')); + $sql_extra .= " AND (`name` REGEXP ? OR `url` REGEXP ? OR `nick` REGEXP ? OR `addr` REGEXP ? OR `alias` REGEXP ?)"; + $sql_values[] = $search_txt; + $sql_values[] = $search_txt; $sql_values[] = $search_txt; $sql_values[] = $search_txt; $sql_values[] = $search_txt; -- 2.39.5