Skip to content

Commit 67ebd63

Browse files
authored
Merge pull request #268 from myoshi2891/dev-from-macmini
Fix SRI calculation validation in calc_sri_fix.sh
2 parents 2c5a9b8 + 50bc729 commit 67ebd63

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

calc_sri_fix.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ set -euo pipefail
44

55
# calculate_sri downloads the given URL, computes the SHA-384 SRI hash of its content (base64) and echoes a line "<url> sha384-<base64_hash>".
66
calculate_sri() {
7-
url="$1"
7+
local url="$1"
8+
local temp_file
89
temp_file=$(mktemp)
9-
trap 'rm -f "$temp_file"' RETURN
10+
trap "rm -f \"$temp_file\"" RETURN
1011

1112
# curl options: -f (fail on HTTP error), -S (show error), -s (silent equivalent), -L (follow redirects)
1213
if ! curl -fS -sL "$url" -o "$temp_file"; then
@@ -20,6 +21,7 @@ calculate_sri() {
2021
return 1
2122
fi
2223

24+
local hash
2325
hash=$(openssl dgst -sha384 -binary < "$temp_file" | openssl base64 -A)
2426
echo "$url sha384-$hash"
2527
rm -f "$temp_file"

0 commit comments

Comments
 (0)