From 04c9ddeb6d3b99496c39543ad468d34f4f1adeff Mon Sep 17 00:00:00 2001 From: Richard Kuhnt Date: Sun, 9 Sep 2018 16:57:47 +0200 Subject: [PATCH] autoupdate: Convert base64 encoded hash values --- lib/autoupdate.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/autoupdate.ps1 b/lib/autoupdate.ps1 index 7f69b948e3..90af6308ae 100644 --- a/lib/autoupdate.ps1 +++ b/lib/autoupdate.ps1 @@ -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+)?"