Skip to content

clean ':' from filenames on macOS - #8168

Open
bwrightkc wants to merge 4 commits into
arvidn:RC_2_0from
bwrightkc:RC_2_0
Open

clean ':' from filenames on macOS#8168
bwrightkc wants to merge 4 commits into
arvidn:RC_2_0from
bwrightkc:RC_2_0

Conversation

@bwrightkc

Copy link
Copy Markdown

libtorrent currently sanitizes ':' on Windows but not on macOS.
Since ':' is illegal on HFS+/APFS, this results in unusable filenames being passed to clients on macOS.
This patch adds ':' to invalid_chars for APPLE builds, consistent with Windows handling.

make ':' an invalid character for macOS clients
@bwrightkc bwrightkc changed the title Update torrent_info.cpp clean ':' from filenames on macOS Feb 24, 2026
@arvidn

arvidn commented Feb 24, 2026

Copy link
Copy Markdown
Owner

do you have a source for this?
https://en.wikipedia.org/wiki/HFS_Plus seems to contradict your assertion

@bwrightkc

Copy link
Copy Markdown
Author

do you have a source for this? https://en.wikipedia.org/wiki/HFS_Plus seems to contradict your assertion

You're right - I have to correct myself - after a quick search, I can't find anything authoritative to back me up on that. macOS does prohibit using a colon in the filename, but apparently that isn't so much a file system restriction as it is a restrictions based on how macOS used to use the colon to separate directories eg bwright:Downloads:My Torrent.torrent.

You can, however, find quite a few people online discussing how macOS doesn't allow you to use a colon in a filename, however. Can also do touch test:file.torrent in Terminal and it will instead create a file with the name test/file.torrent.

@xavier2k6

Copy link
Copy Markdown
Contributor

@xavier2k6

xavier2k6 commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

Perhaps / (forward slash) should be added for Windows??

What is \b for?

static const char invalid_chars[] = "?<>\"|\b*:";

@bwrightkc

Copy link
Copy Markdown
Author

What is \b for?

static const char invalid_chars[] = "?<>\"|\b*:";

\b is the backspace character.

@xavier2k6

Copy link
Copy Markdown
Contributor

backspace character

👍

Ya, googled it afterwards......

@xavier2k6

Copy link
Copy Markdown
Contributor

@arvidn

arvidn commented Mar 6, 2026

Copy link
Copy Markdown
Owner

Ok. it seems like a reasonable change. The main thing I worry about with changing this filter is if someone has downloaded (and is seeding) a torrent with this filename in it. If that person upgrades it will no longer be seeding the file (but possible re-download it under the new name).

But if it hasn't been possible to create these files on mac anyway, it shouldn't be a problem.

@arvidn

arvidn commented Mar 6, 2026

Copy link
Copy Markdown
Owner

the unit tests need to be updated

fix unit test for macOS disliking colons
Comment thread src/torrent_info.cpp Outdated
bwrightkc and others added 2 commits March 6, 2026 18:35
Co-authored-by: Arvid Norberg <arvid.norberg@gmail.com>
@vafada

vafada commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

touch test:file.torrent

i tried this and it created test:file.torrent on my Mac

Screenshot 2026-03-06 at 9 34 54 PM

@bwrightkc

Copy link
Copy Markdown
Author

touch test:file.torrent

i tried this and it created test:file.torrent on my Mac
Screenshot 2026-03-06 at 9 34 54 PM

Correct. Note, however, that when you go look for the file in Finder, it will be named test/file.torrent. My understanding of this is that classic macOS used : as the folder separator, unix uses /, and OS X at release wanted to keep the capability of referencing paths using : in applications so finder translates : to /.

@vafada

vafada commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

touch test:file.torrent

i tried this and it created test:file.torrent on my Mac
Screenshot 2026-03-06 at 9 34 54 PM

Correct. Note, however, that when you go look for the file in Finder, it will be named test/file.torrent. My understanding of this is that classic macOS used : as the folder separator, unix uses /, and OS X at release wanted to keep the capability of referencing paths using : in applications so finder translates : to /.

Oh yes, I see now. Though it doesn't seems like : is an invalid character... Its just Finder being dumb 🤷

@arvidn

arvidn commented Mar 8, 2026

Copy link
Copy Markdown
Owner

I think this makes my concern much stronger. Anyone, on a Mac, seeding a torrent where a filename has a : in it would break on an upgrade.

@101Dude

101Dude commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

I think the issue can be summarized as follows:

Stored  ":"  → Finder displays "/"
Typed "/"   → Finder stores ":"
Typed ":"   → Finder rejects it and reverts to Stored  ":"  → Finder displays "/"

The only issue with colons in filenames is that Finder.app won't show them as colons.

Therefore this PR would not make an otherwise unusable torrent usable. It would change a valid on-disk filename solely to work around how Finder displays it.

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.

5 participants