Skip to content

Commit 310096e

Browse files
committed
autoupdate: improve base64 hash detection
1 parent 805b06a commit 310096e

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/autoupdate.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function find_hash_in_textfile([String] $url, [String] $basename, [String] $rege
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})$') {
6060
$base64 = $matches[0]
61-
if(!($hash -match "^([a-fA-F0-9]{40,128})$")) {
61+
if(!($hash -match "^[a-fA-F0-9]+$") -and $hash.length -in @(32, 40, 64, 128)) {
6262
try {
6363
$hash = ([System.Convert]::FromBase64String($base64) | ForEach-Object { $_.ToString('x2') }) -join ''
6464
} catch {

0 commit comments

Comments
 (0)