Skip to content

fix(torrent): name the file a torrent is refused for - #622

Merged
linroid merged 2 commits into
mainfrom
fix/torrent-name-errors
Oct 23, 2026
Merged

linroid merged 2 commits into
mainfrom
fix/torrent-name-errors

Conversation

@linroid

@linroid linroid commented Oct 23, 2026

Copy link
Copy Markdown
Owner

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:

Couldn't list the files: Unsafe torrent path component
Couldn't list the files: Colliding torrent paths

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:

Couldn't list the files: Unsafe torrent path component: "tab\u0009here.bin"
Couldn't list the files: Colliding torrent paths: "weird names/Same.bin" and "weird names/same.bin"

and File/directory collision names the file and the folder it clashes with. Names go through the new quotedName: 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-files from 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:jvmTest passes.

`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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T16:01:37.046607Z 47a1146 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Oct 23, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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.
@github-actions

Copy link
Copy Markdown
Contributor

Test Results

 2 199 files  + 5   2 227 suites  +5   56m 33s ⏱️ - 1m 19s
15 322 tests +40  15 054 ✅ +40  268 💤 ±0  0 ❌ ±0 
18 681 runs  +42  18 413 ✅ +42  268 💤 ±0  0 ❌ ±0 

Results for commit 9624b3b. ± Comparison against base commit fd06e90.

@linroid
linroid merged commit edebbd5 into main Oct 23, 2026
14 checks passed
@linroid
linroid deleted the fix/torrent-name-errors branch October 23, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant