From 5170cb9185dbdcada3855de41cbb5a0a9d03bd87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my?= Date: Sun, 1 Jan 2017 13:17:55 +0100 Subject: [PATCH] add support for sha512 hashes / autoupdate custom hash type support --- lib/autoupdate.ps1 | 10 +++++++--- lib/install.ps1 | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/autoupdate.ps1 b/lib/autoupdate.ps1 index 184d42fbe..6fe0f50ea 100644 --- a/lib/autoupdate.ps1 +++ b/lib/autoupdate.ps1 @@ -57,13 +57,17 @@ function getHash([String] $app, $config, [String] $version, [String] $url) $hashfile_url = substitute $config.url @{'$version' = $version; '$url' = $url}; $hashfile = (new-object net.webclient).downloadstring($hashfile_url) - $regex = substitute $config.find @{'$basename' = [regex]::Escape($basename)} + $regex = $config.find + if ($regex -eq $null) { + $regex = "([a-z0-9]+)" + } + $regex = substitute $regex @{'$basename' = [regex]::Escape($basename)} if ($hashfile -match $regex) { $hash = $matches[1] - if ($config.type -eq "sha1") { - $hash = "sha1:$hash" + if ($config.type -and !($config.type -eq "sha256")) { + $hash = $config.type + ":$hash" } } } elseif ($hashmode -eq "download") { diff --git a/lib/install.ps1 b/lib/install.ps1 index 3e1d939f5..d37b36e40 100644 --- a/lib/install.ps1 +++ b/lib/install.ps1 @@ -340,7 +340,7 @@ function check_hash($file, $url, $manifest, $arch) { $type, $expected = 'sha256', $type } - if(@('md5','sha1','sha256') -notcontains $type) { + if(@('md5','sha1','sha256', 'sha512') -notcontains $type) { return $false, "hash type $type isn't supported" }