Repository navigation
Save attachments named after a path into subfolders - #53
Merged
Merged
Conversation
Outlook names a file attached from a folder after its Windows path
(zpo-berufung\reference\akt.md). When --output names a directory,
`post attachment` and `post eml --part` now split such a name on \ and /
and write the file into those subfolders, instead of one file with
backslashes in its name (attachment) or the folders run together
(eml --part, through suggestedFilename).
Only relativePath(forAttachmentNamed:) decides what of a sender's name is
used: empty components, ".", ".." and a leading drive letter are dropped
and each component is sanitized, so a name can no longer reach outside
the output directory ("../../x" used to go straight into
appendingPathComponent).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b3402fed6d
ℹ️ 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".
`part.filename ?? part.suggestedFilename` took `filename=""` as the name, which relativePath turned into a bare `attachment`. An empty name now counts as none, in `post eml/msg --part` and in downloadAttachment, so the part is named `part_2.pdf` as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Outlook names a file attached from a folder after its Windows path:
zpo-berufung\reference\akt.md. Once SwiftMail keeps those backslashes (Cocoanetics/SwiftMail#254), saving such a file goes wrong in two ways:post attachment --output dir/writes one file whose name contains backslashes.post eml --part N --output dir/goes throughsuggestedFilename, which strips\and/, so the folders run together (zpo-berufungreferenceakt.md).Separately,
post attachmentpassed the sender's name straight toappendingPathComponent, so a name like../../.zshrccould write outside the output directory.Fix
OutputPath.destination(for:attachmentNamed:), used bypost attachmentandpost eml/msg --part. When--outputnames a directory, the attachment's name is split on\and/and the file is written into those subfolders, which are created as needed. When--outputnames a file, nothing changes.OutputPath.relativePath(forAttachmentNamed:)is the only place that decides what of a name is kept. It drops empty components,.,..and a leading drive letter, sanitizes each component, and falls back toattachment. The result always stays inside the output directory.--outputhelp for both commands says that folders in a name become subfolders.destination(for:named:)is unchanged, sofetch,pdfand.emlexports behave as before.Tests
OutputPathTests: an Outlook path becomes subfolders; traversal attempts (../../.zshrc,/etc/passwd,C:\…, UNC paths,..\..) stay inside; plain names are unchanged; a file--outputignores the name.main).Checked end to end with the real 74-attachment Outlook mail.
post eml --partbuilt against SwiftMail#254 savedzpo-berufung/training/README.md,…/training/entscheidungen/LIESMICH.md,…/judikatur/zpo-501.mdand…/reference/aufbau.md, each byte-identical to the sender's ZIP.Main is merged in, so this now builds on SwiftMail 1.16.0 (
88c45cb, with #254). With that build,post attachment 21835 --output dir/savedzpo-berufung/training/entscheidungen/LIESMICH.mdandzpo-berufung/training/muster/LIESMICH.mdas two separate files from the real mail.🤖 Generated with Claude Code