summaryrefslogtreecommitdiffstats
path: root/lib/private/Avatar.php
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-02-21 10:32:46 +0100
committerMorris Jobke <hey@morrisjobke.de>2018-02-21 10:32:46 +0100
commit3bea8e05ad92502a318b06016682f30579e8144e (patch)
tree913b50a5be7c728887ce09eac198f89659231879 /lib/private/Avatar.php
parent6591a3bc366874ead2de646ae1ca920277c17bff (diff)
downloadnextcloud-server-3bea8e05ad92502a318b06016682f30579e8144e.tar.gz
nextcloud-server-3bea8e05ad92502a318b06016682f30579e8144e.zip
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>
Diffstat (limited to 'lib/private/Avatar.php')
-rw-r--r--lib/private/Avatar.php2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/private/Avatar.php b/lib/private/Avatar.php
index 352fcf05883..14632075ca1 100644
--- a/lib/private/Avatar.php
+++ b/lib/private/Avatar.php
@@ -263,7 +263,7 @@ class Avatar implements IAvatar {
* @return string
*/
private function generateAvatar($userDisplayName, $size) {
- $text = strtoupper($userDisplayName[0]);
+ $text = mb_strtoupper(mb_substr($userDisplayName, 0, 1), 'UTF-8');
$backgroundColor = $this->avatarBackgroundColor($userDisplayName);
$im = imagecreatetruecolor($size, $size);