Harden avatar handling in the new-message notification bridge
Facebook Messenger on your desktop, without the Facebook clutter
Brought to you by:
kristoffer-r
Originally created by: kristofferR
Follow-up to [#13], addressing two issues CodeRabbit raised while reviewing [#21] (they live in [#13]'s avatar code, so they're fixed here rather than scope-creeping the notification-privacy PR).
avatar_to_temp_png previously accepted any data:image/* base64 payload from the remote page and wrote it to a .png file. It now requires a data:image/png;base64, prefix and verifies the decoded bytes begin with the PNG magic header before writing. Size bounds are unchanged.$TMP/carrier-avatars directory with process-local sequence names and a startup-wide remove_dir_all, so a second instance (multi_instance) could collide on filenames or delete another instance's in-flight avatars. Each process now uses its own carrier-avatars-<pid> directory; startup cleanup clears only our own directory plus empty leftovers (remove_dir never removes a live instance's non-empty dir).cargo fmt / clippy -D warnings clean; cargo test --lib 30 passed. Updated the avatar round-trip test to use real PNG bytes and added rejection cases for non-PNG bytes and non-PNG image subtypes.
Ref [#13]
Ticket changed by: kristofferR
Originally posted by: kristofferR
@coderabbitai review