From 6bdc55e13e918070c8a21c4a5d31b4be09adbe7e Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 20 Sep 2020 09:37:05 +0000 Subject: [PATCH 1/3] Issue 9246: Don't perform fulltext searches on URL --- src/Module/Search/Index.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Module/Search/Index.php b/src/Module/Search/Index.php index 80acd74b94..0cada373c6 100644 --- a/src/Module/Search/Index.php +++ b/src/Module/Search/Index.php @@ -132,6 +132,14 @@ class Index extends BaseSearch } } + // Don't perform a fulltext or tag search on fulltext or tag + // Tags don't look like an URL and the fulltext search does only work with natual words + if (parse_url($search, PHP_URL_SCHEME) && parse_url($search, PHP_URL_HOST)) { + Logger::info('Skipping tag and fulltext search since the search looks like an URL.', ['q' => $search]); + notice(DI::l10n()->t('No results.')); + return $o; + } + $tag = $tag || DI::config()->get('system', 'only_tag_search'); // Here is the way permissions work in the search module... From 2bd1e8cf6509217eedd864c509a9bfbf67819621 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 20 Sep 2020 09:38:31 +0000 Subject: [PATCH 2/3] Corrected comment --- src/Module/Search/Index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Module/Search/Index.php b/src/Module/Search/Index.php index 0cada373c6..712edad023 100644 --- a/src/Module/Search/Index.php +++ b/src/Module/Search/Index.php @@ -132,8 +132,8 @@ class Index extends BaseSearch } } - // Don't perform a fulltext or tag search on fulltext or tag - // Tags don't look like an URL and the fulltext search does only work with natual words + // Don't perform a fulltext or tag search on search results that look like an URL + // Tags don't look like an URL and the fulltext search does only work with natural words if (parse_url($search, PHP_URL_SCHEME) && parse_url($search, PHP_URL_HOST)) { Logger::info('Skipping tag and fulltext search since the search looks like an URL.', ['q' => $search]); notice(DI::l10n()->t('No results.')); From c8f385727e11dcce6b4cb4ae75f3e756b4fb8b72 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 20 Sep 2020 11:19:03 -0400 Subject: [PATCH 3/3] Improve log message language in Module/Search/Index.php Co-authored-by: Steffen K9 --- src/Module/Search/Index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Module/Search/Index.php b/src/Module/Search/Index.php index 712edad023..7f5c7ab87b 100644 --- a/src/Module/Search/Index.php +++ b/src/Module/Search/Index.php @@ -135,7 +135,7 @@ class Index extends BaseSearch // Don't perform a fulltext or tag search on search results that look like an URL // Tags don't look like an URL and the fulltext search does only work with natural words if (parse_url($search, PHP_URL_SCHEME) && parse_url($search, PHP_URL_HOST)) { - Logger::info('Skipping tag and fulltext search since the search looks like an URL.', ['q' => $search]); + Logger::info('Skipping tag and fulltext search since the search looks like a URL.', ['q' => $search]); notice(DI::l10n()->t('No results.')); return $o; }