Skip to content

Commit

Permalink
autoupdate: improve base64 hash detection
Browse files Browse the repository at this point in the history
  • Loading branch information
r15ch13 committed Oct 1, 2018
1 parent 805b06a commit 310096e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/autoupdate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ 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})$') {
$base64 = $matches[0]
if(!($hash -match "^([a-fA-F0-9]{40,128})$")) {
if(!($hash -match "^[a-fA-F0-9]+$") -and $hash.length -in @(32, 40, 64, 128)) {
try {
$hash = ([System.Convert]::FromBase64String($base64) | ForEach-Object { $_.ToString('x2') }) -join ''
} catch {
Expand Down

0 comments on commit 310096e

Please sign in to comment.