Skip to content

Commit

Permalink
autoupdate: Convert base64 encoded hash values
Browse files Browse the repository at this point in the history
  • Loading branch information
r15ch13 committed Sep 9, 2018
1 parent a57aae2 commit 04c9dde
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/autoupdate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ function find_hash_in_textfile([String] $url, [String] $basename, [String] $rege
$hash = $matches[1] -replace ' ',''
}

# 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 { }
}

# find hash with filename in $hashfile (will be overridden by $regex)
if ($hash.Length -eq 0 -and $regex.Length -eq 0) {
$filenameRegex = "([a-fA-F0-9]{32,128})[\x20\t]+.*`$basename(?:[\x20\t]+\d+)?"
Expand Down

0 comments on commit 04c9dde

Please sign in to comment.