Changed autocomplete to escape _ and %, lowercase the tags, and also query for tag names that are preceded by categories to address #630

This commit is contained in:
Matthew Barbour 2019-06-26 22:18:39 -05:00 committed by Shish
parent aa9ce52f47
commit 8d567e9553

View file

@ -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"),