Skip to content

Commit

Permalink
fix UTF-8 encoding issue in base64Data function
Browse files Browse the repository at this point in the history
  • Loading branch information
vildanbina committed Nov 21, 2024
1 parent 6995ebb commit 1ae9e59
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/Handlers/HMAC/Hmac.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ abstract class Hmac
*/
public function uri($uri = null)
{
if ($uri)
{
if ($uri) {
$uri = preg_replace("#^[^:/.]*[:/]+#i", "", $uri);

$this->uri = strtolower(urlencode($uri));
Expand All @@ -46,11 +45,13 @@ public function base64Data($data = null)
{
$this->base64Data = '';

if ($data)
{
if (is_array($data))
{
$data = json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION);
if ($data) {
if (is_array($data)) {
$data = mb_convert_encoding(
json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE),
'UTF-8',
'auto'
);
}

$md5 = md5($data, true);
Expand All @@ -67,8 +68,7 @@ public function base64Data($data = null)
*/
public function nonce($nonce = null)
{
if ($nonce)
{
if ($nonce) {
$this->nonce = $nonce;
}

Expand All @@ -81,8 +81,7 @@ public function nonce($nonce = null)
*/
public function time($time = null)
{
if ($time)
{
if ($time) {
$this->time = $time;
}

Expand Down

0 comments on commit 1ae9e59

Please sign in to comment.