Skip to content

Commit

Permalink
Base64url to base64 fix around padding
Browse files Browse the repository at this point in the history
  • Loading branch information
tcharp38 committed Jul 4, 2024
1 parent 068401b commit ac9e610
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
8 changes: 2 additions & 6 deletions core/class/AbeilleTools.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1170,12 +1170,8 @@ public static function base64url2base64($data) {
// Convert Base64URL to Base64 by replacing “-” with “+” and “_” with “/”
$b64 = strtr($data, '-_', '+/');

// Adding padding if required to have length as multiple of 3 bytes
$len = strlen($b64) % 3;
if ($len)
$b64 .= '=';
if ($len > 1)
$b64 .= '=';
// Adding padding if required
$b64 = str_pad($b64, strlen($b64) % 4, '=', STR_PAD_RIGHT);

return $b64;
}
Expand Down
4 changes: 2 additions & 2 deletions core/php/AbeilleCmd-Tuya.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ function tuyaZosung($net, $addr, $ep, $command) {
),
);
$irMsgJson = json_encode($irMsg, JSON_UNESCAPED_SLASHES);
cmdLog2('debug', $addr, ' TEMPORARY: irMsgJson='.$irMsgJson);
cmdLog2('debug', $addr, ' irMsgJson='.$irMsgJson);
$message = bin2hex($irMsgJson);
cmdLog2('debug', $addr, ' TEMPORARY: message='.$message);
cmdLog2('debug', $addr, ' irMsgHex='.$message);
$seq = tuyaZosungSeq(); // For unknown reason, seq above 9 breaks the transfer

// Saving message to send
Expand Down
1 change: 1 addition & 0 deletions docs/fr_FR/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Améliorations placement réseau
- La télécommande virtuelle n'est pas affichée.
- Affichage des équipements pas trouvés dans le réseau sans tête de mort jusqu'a mieux.
- Correction: Format padding base64 utilisé par télécommande universelle.

## 240630-BETA-2

Expand Down

0 comments on commit ac9e610

Please sign in to comment.