diff --git a/base.php b/base.php index 36b3866..0592998 100644 --- a/base.php +++ b/base.php @@ -453,14 +453,19 @@ function matches_comparing_expression($expr, $text) { } else if (strpos($t, 'contains ') === 0) { $w = substr($t, strlen('contains')+1); $w = trim(trim($w, '"')); - $contains = strpos($text, normalize_for_search($w)) !== false; + $contains = strpos(' '.$text.' ', + ' '.normalize_for_search($w).' ') !== false; $result = str_replace($t, $contains ? 'true' : 'false', $result); } } } $result = str_replace('OR', '|', $result); $result = str_replace('AND', '&', $result); - eval('$result = '.$result.';'); + try { + eval('$result = '.$result.';'); + } catch (\Throwable $e) { + return apiresult(['error' => 'Query contains errors, please correct it and try again.']); + } return in_array($result, [0,false]) ? false : true; } diff --git a/views/instance.php b/views/instance.php index fd36f0a..b6d317b 100644 --- a/views/instance.php +++ b/views/instance.php @@ -198,6 +198,7 @@ window.view.instance = { http.get(`api/v1/database/${hargs.software}/accounts/search?${payload}&paging=${page},${items_per_page}`, data, function(js) { if (js === undefined) return toast.error('Could not process the query result'); if (js.ok !== undefined) return toast.info(js.ok); + if (js.error !== undefined) return toast.error(js.error); E.template('users-all', function(TPL) { var html = ''; for (var i = 0; i < js['data'].length; i++) {