Skip to content

Commit

Permalink
chg: [restsearch internal] sanity check erroneous filters
Browse files Browse the repository at this point in the history
  • Loading branch information
iglocska committed Sep 14, 2023
1 parent d14e4c2 commit 08bd232
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions app/Model/AppModel.php
Expand Up @@ -3292,26 +3292,32 @@ public function generic_add_filter($conditions, &$filter, $keys)
foreach ($filters as $f) {
if ($f === -1) {
foreach ($keys as $key) {
$temp['OR'][$key][] = -1;
if ($this->checkParam($key)) {
$temp['OR'][$key][] = -1;
}
}
continue;
}
// split the filter params into two lists, one for substring searches one for exact ones
if (is_string($f) && ($f[strlen($f) - 1] === '%' || $f[0] === '%')) {
foreach ($keys as $key) {
if ($operator === 'NOT') {
$temp[] = array($key . ' NOT LIKE' => $f);
} else {
$temp[] = array($key . ' LIKE' => $f);
$temp[] = array($key => $f);
if ($this->checkParam($key)) {
if ($operator === 'NOT') {
$temp[] = array($key . ' NOT LIKE' => $f);
} else {
$temp[] = array($key . ' LIKE' => $f);
$temp[] = array($key => $f);
}
}
}
} else {
foreach ($keys as $key) {
if ($operator === 'NOT') {
$temp[$key . ' !='][] = $f;
} else {
$temp['OR'][$key][] = $f;
if ($this->checkParam($key)) {
if ($operator === 'NOT') {
$temp[$key . ' !='][] = $f;
} else {
$temp['OR'][$key][] = $f;
}
}
}
}
Expand Down

0 comments on commit 08bd232

Please sign in to comment.