Skip to content

Commit

Permalink
feat(autoupdate): Add base64 decoding for hash values fetched in json…
Browse files Browse the repository at this point in the history
… mode
  • Loading branch information
AkariiinMKII committed Jan 15, 2025
1 parent ac6f1ba commit 6a65c5f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/autoupdate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,19 @@ function find_hash_in_json([String] $url, [Hashtable] $substitutions, [String] $
if (!$hash) {
$hash = json_path_legacy $json $jsonpath $substitutions
}

# convert base64 encoded hash values
if ($hash -match '^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{4})$') {
$base64 = $matches[0]
if (!($hash -match '^[a-fA-F0-9]+$') -and $hash.Length -notin @(32, 40, 64, 128)) {
try {
$hash = ([System.Convert]::FromBase64String($base64) | ForEach-Object { $_.ToString('x2') }) -join ''
} catch {
$hash = $hash
}
}
}

return format_hash $hash
}

Expand Down

0 comments on commit 6a65c5f

Please sign in to comment.