Skip to content

fix(toolchain)!: restrict named toolchain characters - #4932

Open
cachebag wants to merge 2 commits into
rust-lang:mainfrom
cachebag:main
Open

fix(toolchain)!: restrict named toolchain characters#4932
cachebag wants to merge 2 commits into
rust-lang:mainfrom
cachebag:main

Conversation

@cachebag

@cachebag cachebag commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Partially addresses #4059 by restricting what characters a named toolchain may contain.

Named toolchains are now validated against the UTS #39 general security profile.

In essence; unicode_security::GeneralSecurityProfile::identifier_allowed() vs this hand-rolled pattern we had before. Letters and digits in any script stay legal, so 合法的 still works, as do ., _ and -. Whitespace, most punctuation, emoji, and invisible or direction-altering characters are rejected. I also exclude : (NTFS alternate data streams) and ' (shell quoting), plus . and .., which the profile allows.

This is breaking for unusual names like foo#bar or names with spaces. However it doesn't touch the rust-toolchain.toml diagnostics. Confusables are also still unresolved (i.e.μ vs µ, precomposed vs decomposed é).

@cachebag

Copy link
Copy Markdown
Contributor Author

Note to myself that this will probably need some corrections once #4930 is merged

@cachebag
cachebag force-pushed the main branch 4 times, most recently from 1318f92 to 9118fcc Compare June 30, 2026 14:11
Comment thread src/toolchain/names.rs
Comment thread src/toolchain/names.rs Outdated
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rami3l

rami3l commented Jun 30, 2026

Copy link
Copy Markdown
Member

@cachebag Thanks for this PR!

I think given your comment in #4932 (comment) I'll probably review #4930 first and come back to this one later, many thanks for your understanding 🙏

Comment thread src/toolchain/names.rs Outdated
Comment thread src/toolchain/names.rs Outdated
Comment thread src/toolchain/names.rs
@cachebag
cachebag force-pushed the main branch 7 times, most recently from 86f5e64 to b8c8bb9 Compare June 30, 2026 21:07
@cachebag
cachebag requested a review from djc June 30, 2026 21:09
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@cachebag
cachebag force-pushed the main branch 4 times, most recently from 913f977 to a8ed506 Compare June 30, 2026 23:07
Comment thread src/toolchain/names.rs Outdated
Comment thread src/toolchain/names.rs Outdated
Comment thread src/toolchain/names.rs Outdated
Comment thread src/toolchain/names.rs Outdated
Comment thread src/toolchain/names.rs Outdated
Comment thread src/toolchain/names.rs Outdated
Comment thread src/toolchain/names.rs Outdated
@cachebag
cachebag requested a review from rami3l July 1, 2026 13:10
@rami3l rami3l changed the title fix(toolchain): restrict named toolchain characters fix(toolchain)!: restrict named toolchain characters Jul 1, 2026
@cachebag
cachebag force-pushed the main branch 2 times, most recently from b1e3812 to 39fbbcc Compare July 1, 2026 23:59
@rami3l rami3l self-assigned this Jul 3, 2026
@rami3l

rami3l commented Jul 3, 2026

Copy link
Copy Markdown
Member

@cachebag Sorry for the delay in reviewing! I have to see if the current code can be further streamlined and what we should do about #4059 (comment). Please stay tuned...

@cachebag
cachebag marked this pull request as draft July 6, 2026 01:26
@cachebag
cachebag force-pushed the main branch 6 times, most recently from 8e4516c to 39f608c Compare July 13, 2026 13:01
@cachebag
cachebag force-pushed the main branch 3 times, most recently from d14a77d to 4259f6e Compare July 20, 2026 00:46
@rustbot

This comment has been minimized.

@cachebag
cachebag force-pushed the main branch 3 times, most recently from 417f74c to 028f723 Compare August 3, 2026 14:24
@cachebag
cachebag marked this pull request as ready for review August 3, 2026 14:40

@rami3l rami3l left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM modulo some tiny nits, nice work! 🙏

View changes since this review

Comment thread src/toolchain/names.rs
Comment thread src/toolchain/names.rs
Comment thread doc/user-guide/src/concepts/toolchains.md
Comment thread src/toolchain/names.rs
@rustbot

rustbot commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

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.

4 participants