Skip to content

Commit 98afb99

Browse files
committed
autoupdate: Fix base64 hash extraction
1 parent 7b5e551 commit 98afb99

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/autoupdate.ps1

+7-4
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,13 @@ function find_hash_in_textfile([String] $url, [String] $basename, [String] $rege
5757

5858
# convert base64 encoded hash values
5959
if ($hash -match '^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{4})$') {
60-
try {
61-
$hash = ([System.Convert]::FromBase64String($matches[0]) | ForEach-Object { $_.ToString('x2') }) -join ''
62-
} catch {
63-
$hash = $hash
60+
$base64 = $matches[0]
61+
if(!($hash -match "^([a-fA-F0-9]{40,128})$")) {
62+
try {
63+
$hash = ([System.Convert]::FromBase64String($base64) | ForEach-Object { $_.ToString('x2') }) -join ''
64+
} catch {
65+
$hash = $hash
66+
}
6467
}
6568
}
6669

0 commit comments

Comments
 (0)