Fix content search with word ending with hyphen (#7103)

* Fix content search with word ending with hyphen

* Update CHANGELOG.md
This commit is contained in:
Yuriy Bakhtin 2024-07-02 16:24:51 +03:00 committed by GitHub
parent b438d271b1
commit 9c30e05316
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View File

@ -1,6 +1,10 @@
HumHub Changelog
================
1.16.2 (Unreleased)
---------------------
- Fix #7102: Fix content search with word ending with hyphen
1.16.1 (July 1, 2024)
---------------------
- Fix #7084: Fix compatibility for PHP 8.0+

View File

@ -158,6 +158,9 @@ class MysqlDriver extends AbstractDriver
protected function prepareTerm(string $term): string
{
// Remove chars `-` to avoid mysql error
$term = preg_replace('/-+(\*?)$/', '$1', $term);
// Wrap a keyword in quotes to avoid error with the special chars in the sql MATCH-AGAINST expression
return preg_match('#[^\p{L}\d\*\'`\-\_]#', $term) ? '"' . $term . '"' : $term;
}