Skip to content

Commit

Permalink
Look at bytes instead of characters.
Browse files Browse the repository at this point in the history
Looking at characters can yield the wrong results when multibyte
characters are encountered.
  • Loading branch information
markstory committed Mar 23, 2015
1 parent d77a4c1 commit f7470f4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Utility/Security.php
Expand Up @@ -248,8 +248,8 @@ protected static function _constantEquals($hmac, $compare)
if (function_exists('hash_equals')) {
return hash_equals($hmac, $compare);
}
$hashLength = mb_strlen($hmac, '8bit');
$compareLength = mb_strlen($compare, '8bit');
$hashLength = strlen($hmac);
$compareLength = strlen($compare);
if ($hashLength !== $compareLength) {
return false;
}
Expand Down

0 comments on commit f7470f4

Please sign in to comment.