Skip to content

Commit

Permalink
autoupdate: Fix base64 hash extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
r15ch13 committed Sep 10, 2018
1 parent 7b5e551 commit 98afb99
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/autoupdate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,13 @@ function find_hash_in_textfile([String] $url, [String] $basename, [String] $rege

# 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})$') {
try {
$hash = ([System.Convert]::FromBase64String($matches[0]) | ForEach-Object { $_.ToString('x2') }) -join ''
} catch {
$hash = $hash
$base64 = $matches[0]
if(!($hash -match "^([a-fA-F0-9]{40,128})$")) {
try {
$hash = ([System.Convert]::FromBase64String($base64) | ForEach-Object { $_.ToString('x2') }) -join ''
} catch {
$hash = $hash
}
}
}

Expand Down

0 comments on commit 98afb99

Please sign in to comment.