Skip to content

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

Merged
rami3l merged 3 commits into
rust-lang:mainfrom
cachebag:main
Aug 5, 2026
Merged

fix(toolchain)!: restrict named toolchain characters#4932
rami3l merged 3 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
@cachebag
cachebag force-pushed the main branch 4 times, most recently from 39f608c to dca40d2 Compare July 14, 2026 20:23
@cachebag
cachebag force-pushed the main branch 2 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 Outdated
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.

Comment thread src/toolchain/names.rs

@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, thanks a whole lot for the work!

I'll ask @ChrisDenton for one additional round just to make sure that this new pattern looks good to everyone :)

View changes since this review

Comment thread src/toolchain/names.rs Outdated
Comment thread doc/user-guide/src/concepts/toolchains.md Outdated
@rami3l
rami3l added this pull request to the merge queue Aug 5, 2026
Merged via the queue into rust-lang:main with commit ac3ea6c Aug 5, 2026
31 checks passed
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