[pve-devel] [PATCH common] fix #3747: download_file_from_url: trim whitespace before comparing checksum

Fabian Ebner f.ebner at proxmox.com
Fri Dec 3 09:03:26 CET 2021


Am 02.12.21 um 14:38 schrieb Oguz Bektas:
> so that we don't get checksum mismatch in case the user accidentally
> copies whitespace in the checksum field.
> 

Isn't this better done in the UI? Or at least upon parameter validation 
(but we don't do this for any other parameter, or)?.

> Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
> ---
>   src/PVE/Tools.pm | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm
> index 787942a..fa14f2f 100644
> --- a/src/PVE/Tools.pm
> +++ b/src/PVE/Tools.pm
> @@ -1921,6 +1921,7 @@ sub download_file_from_url {
>   	if (defined($opts->{"${_}sum"})) {
>   	    $checksum_algorithm = $_;
>   	    $checksum_expected = $opts->{"${_}sum"};
> +	    $checksum_expected =~ s/^\s+|\s+$//g;
>   	    last;
>   	}
>       }
> 





More information about the pve-devel mailing list