feat: show received file transfers as tappable attachments - #1692
feat: show received file transfers as tappable attachments#1692Chessing234 wants to merge 3 commits into
Conversation
The wire already stores PDFs and other files under files/incoming, but the timeline only rendered [voice] and [image], so [file] notes.pdf was plain text with no way to open or share it.
Cover that a file transfer is not classified as an image attachment.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c1e19a097f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if let url = url(for: .file) { | ||
| return .file(url) |
There was a problem hiding this comment.
Reject traversal names before creating file attachments
A peer can send an ordinary text message such as [file] ../../../prekeys/bundles.json: ChatTransportEventCoordinator constructs messages directly from untrusted packet.content, while this helper appends that unsanitized suffix to files/files/incoming. The new .file branch turns that resolved path into FileAttachmentView, whose ShareLink can export the resulting file outside the media directories (including Application Support data) when the recipient taps it. Normalize to a basename and verify the standardized URL remains under the selected media directory before returning .file.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
basename only now, same as cleanup. traversal names never become an attachment.
A spoofed text bubble can carry [file] ../prekeys/… and ShareLink would export the resolved path. Real transfers already store a basename; require that and keep the URL inside the media directory.
Summary
files/incoming, butmediaAttachmentonly returned.voice/.image, so[file] notes.pdfrendered as ordinary chat text with no way to open it.[file]prefix the same way as the others and render a share / cancel / delete row. Reuses existingmedia.image.*strings — no new catalog keys.Test plan
swiftctypecheck ofBitchatMessage+Media.swiftunder Swift 5swiftctypecheck ofFileAttachmentView.swiftunder Swift 5 and 6xcodebuildtest suite — this machine has Command Line Tools only, no Xcode; CI coversBitchatMessageMediaTestsand the view wiring