Repository navigation
fix(torrent): name the file a torrent is refused for - #622
Conversation
`ketch --list-files` on a torrent with a tab in a file name, or with Same.bin beside same.bin, said only "Unsafe torrent path component" or "Colliding torrent paths", with nothing to tell which file. The unsafe name and colliding paths errors, and the file/directory collision one, now quote the names, with control and bidirectional formatting characters escaped and at most 80 characters shown.
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. |
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 47a1146e75
ℹ️ 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".
…name errors Two names can clean to the same stored path (a?.txt and a*.txt), so the collision errors now quote each file as the metainfo lists it. quotedName escapes C1 controls and the whole Bidi_Control set, as core's sanitizeFileName removes them.
Found while feeding Ketch torrents with tricky file names. It refuses a torrent whose names can't be stored safely, by design: control characters,
./.., and paths that collide once cleaned, ignoring case. But the error didn't say which file:With hundreds of files there's no way to tell why the torrent was refused.
What changes
The three refusals now quote the names involved:
and
File/directory collisionnames the file and the folder it clashes with. Names go through the newquotedName: control characters and bidirectional formatting characters (U+200E/F, U+202A–U+202E, U+2066–U+2069) are escaped as\uXXXX, so a hostile name can't rewrite what a terminal or log shows, and at most 80 characters are shown. Which torrents are refused doesn't change.Verification
ketch --list-filesfrom this branch on torrents built with those names prints the messages above.TorrentMetadataTest: the collision test checks the named paths, and a new test checks an unsafe name with a tab and a U+202E override is quoted escaped../gradlew :library:torrent:jvmTestpasses.