diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2019-12-04 17:38:44 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-04 17:38:44 +0300 |
commit | 5de8f9b37e5f361d5e3ff6880c0ad57bbfe6c32e (patch) | |
tree | 3d17f7f0770565951a7ce9eaaa7e3874a9bf5d07 | |
parent | 9d2bdd3f4a8ef9b0807dfb444c76e7468501c8e4 (diff) | |
parent | ae6a18c31d73cefd3eb68b6ca98a44432b391e02 (diff) |
Merge pull request #496 from nextcloud/bugfix/488/fix-cutting-of-multibyte-charsv18.0.0beta1
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 bc25486..810a003 100644 --- a/lib/Push.php +++ b/lib/Push.php @@ -264,9 +264,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; } |