Permit whitespace when verifying openssl-dgst format, to make it also
work for the shasum format used by tarsnap.  However, given the changes
seem to be merely whitespace, just accept both rather than having two
confusing names for them.

    openssl-dgst: SHA256(filename)=digest
    shasum: SHA256 (filename) = digest

Closes: https://bugs.gentoo.org/969167
Signed-off-by: Michał Górny <[email protected]>
---
 eclass/verify-sig.eclass | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Changes in v2: using regex, hopefully in the end it will be easier to
comprehend than all the string manipulations.

diff --git a/eclass/verify-sig.eclass b/eclass/verify-sig.eclass
index 823e8f02a2c9e..d9aa60152a091 100644
--- a/eclass/verify-sig.eclass
+++ b/eclass/verify-sig.eclass
@@ -344,11 +344,10 @@ verify-sig_verify_unsigned_checksums() {
                                [[ -n ${junk} ]] && continue
                                ;;
                        openssl-dgst)
-                               [[ ${line} != *"("*")="* ]] && continue
-                               checksum=${line##*)=}
-                               algo=${line%%(*}
-                               filename=${line#*(}
-                               filename=${filename%)=*}
+                               [[ ${line} =~ 
^([[:alnum:]]+)[[:space:]]*[(](.*)[)][[:space:]]*=[[:space:]]*([0-9a-fA-F]+)$ 
]] || continue
+                               algo=${BASH_REMATCH[1]}
+                               filename=${BASH_REMATCH[2]}
+                               checksum=${BASH_REMATCH[3]}
                                ;;
                esac
 

Reply via email to