Skip to content

Commit

Permalink
Add support for multibyte string
Browse files Browse the repository at this point in the history
Issue dapphp#5 : Cannot authentificate with a specific special character in password.
Add support for multibyte string (https://www.php.net/manual/en/book.mbstring.php) in str2unicode function (Pear_CHAP.php).
Function interprets all characters with 1 byte (basic UTF-8) while special characters are encoded with more than 1 byte (see column UTF-8(hex.) in https://www.utf8-chartable.de/unicode-utf8-table.pl?names=-&unicodeinhtml=hex).
  • Loading branch information
mportelag authored Aug 2, 2019
1 parent 1954c34 commit 5c9b0b0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Pear_CHAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ public function str2unicode($str)
{
$uni = '';
$str = (string) $str;
for ($i = 0; $i < strlen($str); $i++) {
$a = ord($str{$i}) << 8;
for ($i = 0; $i < mb_strlen($str); $i++) {
$a = mb_ord(mb_substr($str,$i,1)) << 8;
$uni .= sprintf("%X", $a);
}
return pack('H*', $uni);
Expand Down

0 comments on commit 5c9b0b0

Please sign in to comment.