From 8e473a4fb49805ddce3c6833def78d5a2780b22f Mon Sep 17 00:00:00 2001 From: bitcoin333 Date: Fri, 27 May 2016 09:27:39 +0200 Subject: Update LetterAvatarProvider.php Correct UFT-8 handling. --- app/User/Avatar/LetterAvatarProvider.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/User') diff --git a/app/User/Avatar/LetterAvatarProvider.php b/app/User/Avatar/LetterAvatarProvider.php index f9659e61..b7a95f41 100644 --- a/app/User/Avatar/LetterAvatarProvider.php +++ b/app/User/Avatar/LetterAvatarProvider.php @@ -144,12 +144,12 @@ class LetterAvatarProvider extends Base implements AvatarProviderInterface $str .= 'x'; $max = intval(9007199254740991 / $seed2); - for ($i = 0, $ilen = mb_strlen($str); $i < $ilen; $i++) { + for ($i = 0, $ilen = mb_strlen($str, 'UTF-8'); $i < $ilen; $i++) { if ($hash > $max) { $hash = intval($hash / $seed2); } - $hash = $hash * $seed + $this->getCharCode($str[$i]); + $hash = $hash * $seed + $this->getCharCode(mb_substr($str, $i, 1, 'UTF-8')); } return $hash; -- cgit v1.2.3