Commit 86fac48b authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:ambulance: fix(plugins) Avoid using substr to truncate utf8 data

This avoids JSON encoding errors in the webservice and other bugs
 related to strings getting truncated in the middle of a multibyte character.

issue #5799
Showing with 5 additions and 5 deletions
+5 -5
......@@ -321,8 +321,8 @@ class argonautQueue extends simpleManagement
if ($infos) {
$str = $infos['name'];
if (strlen($str) > 20) {
$str = substr($str, 0, 18)."...";
if (mb_strlen($str) > 20) {
$str = mb_substr($str, 0, 18)."...";
}
$str = htmlentities($str, ENT_COMPAT, 'UTF-8');
......
......@@ -273,7 +273,7 @@ class mailMethodRenaterPartage extends mailMethod
}
}
$account['zimbraAccountStatus'] = ($mainTab->attributesAccess['userPassword']->isLocked() ? 'locked' : 'active');
$account['initials'] = strtoupper(substr($mainTab->givenName, 0, 1).substr($mainTab->sn, 0, 1));
$account['initials'] = mb_strtoupper(mb_substr($mainTab->givenName, 0, 1).mb_substr($mainTab->sn, 0, 1));
/* Sync fields from SUPANN if tab is active */
if (isset($this->parent->parent->by_object['supannAccount']) && $this->parent->parent->by_object['supannAccount']->is_account) {
......
......@@ -74,8 +74,8 @@ class supann
/* return the 64 first chars and "…" after if text is longer */
static function truncate_label($str, $len = 50)
{
if (strlen($str) > $len) {
return substr($str, 0, $len).'…';
if (mb_strlen($str) > $len) {
return mb_substr($str, 0, $len).'…';
} else {
return $str;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment