Merge pull request #18399 from nextcloud/backport/18302/stable17
[stable17] Fix comments search result to work with multibyte strings
This commit is contained in:
commit
678cbd53af
1 changed files with 5 additions and 5 deletions
|
@ -80,12 +80,12 @@ class Result extends BaseResult {
|
|||
* @throws NotFoundException
|
||||
*/
|
||||
protected function getRelevantMessagePart(string $message, string $search): string {
|
||||
$start = stripos($message, $search);
|
||||
$start = mb_stripos($message, $search);
|
||||
if ($start === false) {
|
||||
throw new NotFoundException('Comment section not found');
|
||||
}
|
||||
|
||||
$end = $start + strlen($search);
|
||||
$end = $start + mb_strlen($search);
|
||||
|
||||
if ($start <= 25) {
|
||||
$start = 0;
|
||||
|
@ -95,15 +95,15 @@ class Result extends BaseResult {
|
|||
$prefix = '…';
|
||||
}
|
||||
|
||||
if ((strlen($message) - $end) <= 25) {
|
||||
$end = strlen($message);
|
||||
if ((mb_strlen($message) - $end) <= 25) {
|
||||
$end = mb_strlen($message);
|
||||
$suffix = '';
|
||||
} else {
|
||||
$end += 25;
|
||||
$suffix = '…';
|
||||
}
|
||||
|
||||
return $prefix . substr($message, $start, $end - $start) . $suffix;
|
||||
return $prefix . mb_substr($message, $start, $end - $start) . $suffix;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue