Commit b4862190 authored by NetPuter's avatar NetPuter

Use `mb_substr` instead of `sub_str` in order to resolve multi-language problem.

parent d2fefa65
......@@ -129,7 +129,14 @@ class Crypter {
*/
protected static function unpad($value)
{
$pad = ord($value[($length = Str::length($value)) - 1]);
if (MB_STRING)
{
$pad = ord(mb_substr($value, -1, 1, Config::get('application.encoding')));
}
else
{
$pad = ord(substr($value, -1));
}
if ($pad and $pad < static::$block)
{
......@@ -138,7 +145,12 @@ class Crypter {
// as the padding appears to have been changed.
if (preg_match('/'.chr($pad).'{'.$pad.'}$/', $value))
{
return substr($value, 0, $length - $pad);
if (MB_STRING)
{
return mb_substr($value, 0, Str::length($value) - $pad, Config::get('application.encoding'));
}
return substr($value, 0, Str::length($value) - $pad);
}
// If the padding characters do not match the expected padding
......@@ -163,4 +175,4 @@ class Crypter {
return Config::get('application.key');
}
}
\ No newline at end of file
}
Markdown is supported
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