fix(installer): tolerate BOM, CRLF, and uppercase in older manifests (Bash)
Bash's manifest reader stripped only the trailing newline, so a CRLF-terminated manifest left a stray \r on every hash, a UTF-8 BOM on the header line was folded into the "path" field, and an uppercase hash never matched sha256sum's lowercase output. Reproduced against a real manifest written by an earlier version of the PowerShell installer, where every single managed file was misreported as locally modified. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
1c2d155fcc
commit
0ae373c202
@@ -24,8 +24,14 @@ read_managed_manifest() {
|
||||
[ -f "$path" ] || return 0
|
||||
local rel hash first=1
|
||||
while IFS=$'\t' read -r rel hash; do
|
||||
if [ "$first" = 1 ]; then first=0; [ "$rel" = path ] && continue; fi
|
||||
hash=${hash%$'\r'} # tolerate a CRLF-terminated manifest (read only strips the trailing \n)
|
||||
if [ "$first" = 1 ]; then
|
||||
first=0
|
||||
rel=${rel#$'\xef\xbb\xbf'} # tolerate a UTF-8 BOM on the header line
|
||||
[ "$rel" = path ] && continue
|
||||
fi
|
||||
[ -n "$rel" ] || continue
|
||||
hash=$(printf '%s' "$hash" | tr '[:upper:]' '[:lower:]') # tolerate uppercase hashes from older manifests
|
||||
out_ref[$rel]=$hash
|
||||
done < "$path"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user