diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2019-12-04 21:49:44 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-04 21:49:44 +0300 |
commit | 2a185f7e52a44b11ef6865bd4548a04015a46db3 (patch) | |
tree | 446825db8956cf7fa43a49b47397b1a920803129 | |
parent | ebe9d4aeb4dd10155162b00450374f12c6c6a6c5 (diff) | |
parent | c1c0cd57456bd2b4fb7998af5e2b2e6394ef300f (diff) |
Merge pull request #500 from nextcloud/backport/496/stable16v16.0.7RC1
[stable16] Fix cutting of multibyte characters
-rw-r--r-- | lib/Push.php | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Push.php b/lib/Push.php index e5f3e31..f381d20 100644 --- a/lib/Push.php +++ b/lib/Push.php @@ -194,9 +194,10 @@ class Push { // Max length of encryption is 255, so we need to shorten the subject to be shorter $subject = $notification->getParsedSubject(); - $dataLength = 245 - strlen(json_encode($data)); + // Half the length for multibyte characters like Russian, Chinese, Japanese, Emojis, … + $dataLength = floor((245 - strlen(json_encode($data))) / 2) - 1; if (strlen($subject) > $dataLength) { - $data['subject'] = substr($subject, 0, $dataLength) . '…'; + $data['subject'] = mb_substr($subject, 0, $dataLength) . '…'; } else { $data['subject'] = $subject; } |