fix multi-byte handling in excerpt for dashboard

Signed-off-by: Benjamin Schmid <bentolor@users.noreply.github.com>
This commit is contained in:
Benjamin Schmid 2020-11-23 20:57:05 +01:00 committed by GitHub
parent d4d75b2e50
commit a4a282c87a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -62,14 +62,14 @@ class Note {
$excerpt = trim($this->noteUtil->stripMarkdown($this->getContent()));
$title = $this->getTitle();
if (!empty($title)) {
$length = strlen($title);
$length = mb_strlen($title, "utf-8");
if (strncasecmp($excerpt, $title, $length) === 0) {
$excerpt = substr($excerpt, $length);
$excerpt = mb_substr($excerpt, $length, null, "utf-8");
}
}
$excerpt = trim($excerpt);
if (strlen($excerpt) > $maxlen) {
$excerpt = substr($excerpt, 0, $maxlen) . '…';
if (mb_strlen($excerpt, "utf-8") > $maxlen) {
$excerpt = mb_substr($excerpt, 0, $maxlen, "utf-8") . '…';
}
return str_replace("\n", "\u{2003}", $excerpt);
}