fix(#610): apply Gemini review, harden the card parser and chip
Three accepted findings, plus a real defect the adversarial test cases flushed out. A long name overflowed the chip by 405 pixels. The name comes off a public radio channel and is attacker-controlled, so anyone could break a message list by posting a card with a long name. The label is now bounded and ellipsized, with an explicit width ceiling because a WidgetSpan hands its child unbounded width. fromChannelShare no longer scans from the first < to the last >. Two cards in one message were read as a single span running from the first key to the last name. That was reachable: the add dialog passes raw pasted text straight to it. It now takes the first well-formed card via a regex whose name class cannot cross a closing bracket. The known-contact check is O(1) against the connector's existing _knownContactKeys set, through a new isKnownContact. Scanning contacts ran per chip on every notification, and the public knownContactKeys getter copies the whole set, so neither belonged in a build method. Card-versus-mention is now carried on the match instead of inferred from text[m.start] == '<', which would mis-route the day a third bracketed pattern is added. Two findings were rejected on evidence and are justified in the PR body: a claimed missing null terminator (firmware sets it from the frame length itself) and a claimed greedy-regex failure (disproven by test). Epic #610. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>feat/610-contact-card-receive
parent
cbb3703aba
commit
af036fe6d1
Loading…
Reference in new issue