Skip to content

Commit

Permalink
Merge pull request #211 from TomoTsuyuki/fix-issue62-apostrophe
Browse files Browse the repository at this point in the history
Fix issue #62 Error with apostrophe
  • Loading branch information
jleyva authored Oct 3, 2024
2 parents 4fa58a5 + 35a45ef commit 09ccd7f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion components/filters/fuserfield/plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ private function sql_replace(string $filtersearchtext, $filterstrmatch, $finalel
}
if ($operator === '~') {
// TODO can be improved by more native PDO approach.
$replace = " AND " . $field . " LIKE '%" . $filtersearchtext . "%'";
$searchitem = trim(str_replace("'", "''", $filtersearchtext));
$replace = " AND " . $field . " LIKE '%" . $searchitem . "%'";
} else if ($operator === 'in') {
$processeditems = [];

Expand Down
3 changes: 2 additions & 1 deletion components/filters/searchtext/plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ private function sql_replace($filtersearchtext, $filterstrmatch, $finalelements)
}

if ($operator === '~') {
$replace = " AND " . $field . " LIKE '%" . $filtersearchtext . "%'";
$searchitem = trim(str_replace("'", "''", $filtersearchtext));
$replace = " AND " . $field . " LIKE '%" . $searchitem . "%'";
} else if ($operator === 'in') {
$processeditems = [];
// Accept comma-separated values, allowing for '\,' as a literal comma.
Expand Down

0 comments on commit 09ccd7f

Please sign in to comment.