Skip to content

Commit

Permalink
Release v2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
getcompass-opensource committed Apr 23, 2024
1 parent d1bfcb9 commit 86f4fa5
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
class Domain_User_Entity_Search extends MatchBuilder {

protected const _MIN_QUERY_LEN = 1;
protected const _MIN_QUERY_LEN = 2;
protected const _MAX_QUERY_LEN = 255;

/**
Expand All @@ -23,7 +23,7 @@ class Domain_User_Entity_Search extends MatchBuilder {
public static function validateSearchQuery(string $full_name):void {

$query_len = mb_strlen(trim($full_name));
if ($query_len < self::_MIN_QUERY_LEN || $query_len > self::_MAX_QUERY_LEN) {
if ($query_len < 1 || $query_len > self::_MAX_QUERY_LEN) {
throw new ParamException("incorrect search query");
}
}
Expand All @@ -47,11 +47,11 @@ public static function find(string $full_name, int $limit):array {

// чистим всю строку от мусора
$search_query = self::_clearQuery($search_query);
$search_query = self::_escapeQuery($search_query);

// подготавливаем поисковый запрос именно для fulltext mysql
// отрезаем спецсимволы, на которые ругается mysql, подготовливаем слова для поиска
$phrase_mod = trim(preg_replace("/[><()~*:\"&|@+-]/", "", $search_query, -1));
$phrase_mod = trim(preg_replace("/[><()~*:\"';%&|@+-]/", "", $search_query, -1));
$phrase_mod = self::_escapeQuery($phrase_mod);
$raw_search_word_list = preg_split("/[\s,.]/", $phrase_mod, -1, PREG_SPLIT_NO_EMPTY);

// убираем слишком мелкие куски
Expand Down

0 comments on commit 86f4fa5

Please sign in to comment.