Strings/Encoding

* replaced some more uses of string functions with multibyte equivalents where it might matter
   note: i didn't touch the spell-tooltip parser as it seems to work as intended regardless
This commit is contained in:
Sarjuuk
2015-09-19 16:11:10 +02:00
parent 6dc6124673
commit d7c6092d5f
13 changed files with 32 additions and 32 deletions

View File

@@ -307,7 +307,7 @@ class AjaxHandler
// trim to max length
if (!User::isInGroup(U_GROUP_MODERATOR) && mb_strlen($this->post('commentbody')) > $_maxCmt)
$this->post['body'] = substr($this->post('body'), 0, $_maxCmt);
$this->post['body'] = mb_substr($this->post('body'), 0, $_maxCmt);
if (User::canComment() && !empty($this->post('commentbody')) && mb_strlen($this->post('commentbody')) >= $_minCmt)
{
@@ -335,7 +335,7 @@ class AjaxHandler
// trim to max length
if (!User::isInGroup(U_GROUP_MODERATOR) && mb_strlen($this->post('body')) > $_maxCmt)
$this->post['body'] = substr($this->post('body'), 0, $_maxCmt);
$this->post['body'] = mb_substr($this->post('body'), 0, $_maxCmt);
$update = array(
'body' => $this->post('body'),
@@ -965,7 +965,7 @@ class AjaxHandler
}
}
$buff .= 'g_spells.add('.$id.", {id:".$id.", name:'".Util::jsEscape(substr($data['name'], 1))."', icon:'".$data['icon']."', modifier:".Util::toJSON($mods)."});\n";
$buff .= 'g_spells.add('.$id.", {id:".$id.", name:'".Util::jsEscape(mb_substr($data['name'], 1))."', icon:'".$data['icon']."', modifier:".Util::toJSON($mods)."});\n";
}
$buff .= "\n";
}
@@ -1130,7 +1130,7 @@ class AjaxHandler
if ($this->get('type') && intVal($this->get('type')) && $this->get('typeid') && intVal($this->get('typeid')))
$res = CommunityContent::getScreenshotsForManager($this->get('type'), $this->get('typeid'));
else if ($this->get('user') && strlen(urldecode($this->get('user'))) > 2)
else if ($this->get('user') && mb_strlen(urldecode($this->get('user'))) > 2)
if ($uId = DB::Aowow()->selectCell('SELECT id FROM ?_account WHERE displayName = ?', strtolower(urldecode($this->get('user')))))
$res = CommunityContent::getScreenshotsForManager(0, 0, $uId);

View File

@@ -175,7 +175,7 @@ class CommunityContent
// limit whitespaces to one at a time
$c['preview'] = preg_replace('/\s+/', ' ', $c['preview']);
// limit previews to 100 chars + whatever it takes to make the last word full
if (strlen($c['preview']) > 100)
if (mb_strlen($c['preview']) > 100)
{
$n = 0;
$b = [];
@@ -183,7 +183,7 @@ class CommunityContent
while ($n < 100 && $parts)
{
$_ = array_shift($parts);
$n += strlen($_);
$n += mb_strlen($_);
$b[] = $_;
}

View File

@@ -922,9 +922,9 @@ abstract class Filter
$parts = array_filter(explode(' ', $string));
foreach ($parts as $p)
{
if ($p[0] == '-' && strlen($p) > 3)
$sub[] = [$f, sprintf($exPH, substr($p, 1)), '!'];
else if ($p[0] != '-' && strlen($p) > 2)
if ($p[0] == '-' && mb_strlen($p) > 3)
$sub[] = [$f, sprintf($exPH, mb_substr($p, 1)), '!'];
else if ($p[0] != '-' && mb_strlen($p) > 2)
$sub[] = [$f, sprintf($exPH, $p)];
}

View File

@@ -370,7 +370,7 @@ class User
{
$errCode = 0;
if (strlen($name) < 4 || strlen($name) > 16)
if (mb_strlen($name) < 4 || mb_strlen($name) > 16)
$errCode = 1;
else if (preg_match('/[^\w\d]/i', $name))
$errCode = 2;