Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions tests/test_source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ cd "$(dirname "${BASH_SOURCE[0]}")/../ui"

fail() { printf 'test_source.sh: %s\n' "$1" >&2; exit 1; }

# Arch keeps the digest in `sha256sum`; macOS and Perl ship `shasum -a 256`.
# Use whichever is present so the checksum gate runs on either without changing
# which digest it checks: both print the same SHA-256 hex.
sha256_of() {
if command -v sha256sum >/dev/null 2>&1; then
sha256sum "$1" | awk '{print $1}'
elif command -v shasum >/dev/null 2>&1; then
shasum -a 256 "$1" | awk '{print $1}'
else
fail "neither sha256sum nor shasum is installed to verify $1"
fi
}

# Enumerated rather than globbed: the layout groups by module, and a module
# with no QML in it (message/, today) turns a literal glob into a grep error
# that hides whatever the check was meant to say.
Expand Down Expand Up @@ -1087,7 +1100,7 @@ fi
font_provenance=app/assets/fonts/NerdFonts-PROVENANCE.md
[ -f "../$font_provenance" ] || fail "bundled fonts must record their provenance"
while read -r expected file; do
actual=$(cd .. && shasum -a 256 "$file" | awk '{print $1}')
actual=$(cd .. && sha256_of "$file")
[ "$actual" = "$expected" ] || fail "$file does not match its reviewed upstream checksum"
grep -q "$expected" "../$font_provenance" \
|| fail "$file checksum is missing from its shipped provenance"
Expand All @@ -1105,7 +1118,7 @@ mac_icon=app/resources/macos/omamail.icns
[ "$(cd .. && wc -c < "$mac_icon")" -eq 111809 ] \
|| fail "$mac_icon does not match its reviewed byte size"
mac_icon_checksum=bd29ce1e72aa9db37ed5b1cb930956d2d933dc4426e7cea7f1b8baf2edb9262d
actual_mac_icon_checksum=$(cd .. && shasum -a 256 "$mac_icon" | awk '{print $1}')
actual_mac_icon_checksum=$(cd .. && sha256_of "$mac_icon")
[ "$actual_mac_icon_checksum" = "$mac_icon_checksum" ] \
|| fail "$mac_icon does not match its reviewed checksum"
grep -q "$mac_icon_checksum" "../$icon_provenance" \
Expand All @@ -1114,7 +1127,7 @@ grep -q '1277a2cf247b275a15961fb20175420abb5dfc5489acb95313f4f604c09b6e78' "../$
|| fail "the macOS icon source checksum is missing from its shipped provenance"
windows_icon=app/resources/windows/omamail.ico
windows_icon_checksum=2562966adb272711ae0274f7eade7ef2680781bb4405182280a310658752131d
actual_windows_icon_checksum=$(cd .. && shasum -a 256 "$windows_icon" | awk '{print $1}')
actual_windows_icon_checksum=$(cd .. && sha256_of "$windows_icon")
[ "$actual_windows_icon_checksum" = "$windows_icon_checksum" ] \
|| fail "$windows_icon does not match its reviewed checksum"
grep -q "$windows_icon_checksum" "../$icon_provenance" \
Expand Down
20 changes: 19 additions & 1 deletion ui/account/Accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,26 @@ function discardDraftAt(list, index) {
// Empty is not a name and clears it, which is what puts the address back:
// `label()` falls through to the local part, so there is no state in which a
// mailbox has nothing to be called.
// QML 6.12 can hand a value that crossed a signal or `var` boundary back as a
// V4Sequence: not an Array, but a sequence with an integral length and the
// sequence methods (including `slice`). Read one by index into a plain JS
// array. A JSON object can carry a numeric `length` but can never carry a
// function, so an arbitrary object stays rejected, as it was when only
// Array.isArray was accepted; a genuine sequence is the only non-Array that
// gets through. Copy by index rather than enumerating keys, so an own
// "__proto__" is never run as a setter.
function plainList(value) {
if (Array.isArray(value)) return value
if (!value || typeof value !== "object" || typeof value.slice !== "function"
|| typeof value.length !== "number" || !isFinite(value.length)
|| value.length < 0 || Math.floor(value.length) !== value.length) return []
var out = []
for (var i = 0; i < value.length; i++) out.push(value[i])
return out
}

function idList(value) {
var list = Array.isArray(value) ? value : []
var list = plainList(value)
var out = []
for (var i = 0; i < list.length; i++) {
var item = trimmed(list[i])
Expand Down
16 changes: 16 additions & 0 deletions ui/tests/test_accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,22 @@ assert.strictEqual(frozen(accounts.replaceAt(cidActive, -1, account("x@example.c
"and it is written to disk and read back")
}

// The watch list reads a real sequence by index, but must not widen into
// accepting any object that merely carries a numeric length: only a sequence
// (Array or the Qt sequence the shell hands back) has the sequence methods. A
// malformed entry must not turn its keys into watch ids, and an unbounded
// length must not be walked.
deepEqual(accounts.idList({ length: 3, 0: "a", 1: "b", 2: "c" }), [],
"a plain object with a length is not a sequence")
deepEqual(accounts.idList({ length: 1e100 }), [], "an unbounded length is refused")
deepEqual(accounts.idList({ length: Infinity, 0: "a" }), [], "an infinite length is refused")
deepEqual(accounts.idList({ length: -1, 0: "a" }), [], "a negative length is refused")
deepEqual(accounts.idList({ length: 1.5, 0: "a" }), [], "a fractional length is refused")
deepEqual(accounts.idList("Work"), [], "a string is not a sequence")
deepEqual(accounts.idList(null), [], "null is not a sequence")
deepEqual(accounts.idList([" Label_7 ", "Label_7", "", " "]), ["Label_7"],
"trimming and de-duplication are preserved for a real sequence")


// An HTML signature sits beside the plain one and survives its edits.
{
Expand Down
Loading