Use mb_* string methods to extract first character for generated avatars

This fixes #8451 where the first character is a non-ASCII character. The `$string[0]` notation only extracted one byte and thus resulting in an invalid code. The `mb_strtoupper` method also allows to convert characters independently from the current locale on the server.

See also http://php.net/manual/en/function.mb-strtoupper.php

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
Morris Jobke 2018-02-21 10:32:46 +01:00
parent a3de507b76
commit f1568b96ce
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
1 changed files with 1 additions and 1 deletions

View File

@ -246,7 +246,7 @@ class Avatar implements IAvatar {
* @return string
*/
private function generateAvatar($userDisplayName, $size) {
$text = strtoupper(substr($userDisplayName, 0, 1));
$text = mb_strtoupper(mb_substr($userDisplayName, 0, 1), 'UTF-8');
$backgroundColor = $this->avatarBackgroundColor($userDisplayName);
$im = imagecreatetruecolor($size, $size);