From 8d567e95534d58bae5b21c44375772e2341be89a Mon Sep 17 00:00:00 2001 From: Matthew Barbour Date: Wed, 26 Jun 2019 22:18:39 -0500 Subject: [PATCH] Changed autocomplete to escape _ and %, lowercase the tags, and also query for tag names that are preceded by categories to address #630 --- ext/autocomplete/main.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ext/autocomplete/main.php b/ext/autocomplete/main.php index a7c85050..54629897 100644 --- a/ext/autocomplete/main.php +++ b/ext/autocomplete/main.php @@ -38,7 +38,9 @@ class AutoComplete extends Extension //$limit = 0; $cache_key = "autocomplete-$s"; $limitSQL = ""; - $SQLarr = ["search"=>"$s%"]; + $s = str_replace('_','\_', $s); + $s = str_replace('%','\%', $s); + $SQLarr = ["search"=>"$s%", "cat_search"=>"%:$s%"]; if (isset($_GET["limit"]) && $_GET["limit"] !== 0) { $limitSQL = "LIMIT :limit"; $SQLarr['limit'] = $_GET["limit"]; @@ -51,7 +53,8 @@ class AutoComplete extends Extension $database->scoreql_to_sql(" SELECT tag, count FROM tags - WHERE SCORE_STRNORM(tag) LIKE SCORE_STRNORM(:search) + WHERE SCORE_STRNORM(tag) LIKE SCORE_STRNORM(:search) + OR SCORE_STRNORM(tag) LIKE SCORE_STRNORM(:cat_search) AND count > 0 ORDER BY count DESC $limitSQL"),