Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not allow empty feature name #12928

Merged
merged 2 commits into from
Nov 8, 2023

Conversation

Rustin170506
Copy link
Member

@Rustin170506 Rustin170506 commented Nov 7, 2023

What does this PR try to resolve?

Found it when I was working on rust-lang/crates.io#7379

How should we test and review this PR?

See the unit tests and integration tests.

Additional information

Do we have any special reasons to allow empty names? I am not sure. It seems there is no way to use an empty feature.

@rustbot
Copy link
Collaborator

rustbot commented Nov 7, 2023

r? @weihanglo

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 7, 2023
Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

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

Looks great, but this stops packages with empty feature names from compiling, right? Do we know how many of them are in crates.io index and do we want to make them unbuildable?

@Rustin170506
Copy link
Member Author

Do we know how many of them are in crates.io index and do we want to make them unbuildable?

Crates.io doesn't allow empty feature names.

https://github.com/hi-rustin/crates.io/blob/7b34715de4d7e16903f02d70bc9cfd869e266bae/src/models/krate.rs#L227

@ehuss
Copy link
Contributor

ehuss commented Nov 7, 2023

There was an unintentional regression in 1.60 for this due to the switch to toml_edit which followed the spec more closely.

@epage
Copy link
Contributor

epage commented Nov 7, 2023

Oh, did toml 0.5 disallow empty keys?

Should we disallow any other empty keys, like dependency names (only relevant when using package)

@ehuss
Copy link
Contributor

ehuss commented Nov 7, 2023

Yea, it was disallowed. It was fixed by toml-rs/toml-rs#373, but cargo was already switching. I didn't make the connection that some validation would be depending on that.

@Rustin170506 Rustin170506 changed the title Do now allow empty feature name Do not allow empty feature name Nov 8, 2023
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
@epage
Copy link
Contributor

epage commented Nov 8, 2023

@bors r+

@bors
Copy link
Contributor

bors commented Nov 8, 2023

📌 Commit d618164 has been approved by epage

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 8, 2023
@bors
Copy link
Contributor

bors commented Nov 8, 2023

⌛ Testing commit d618164 with merge fed84e0...

@bors
Copy link
Contributor

bors commented Nov 8, 2023

☀️ Test successful - checks-actions
Approved by: epage
Pushing fed84e0 to master...

@bors bors merged commit fed84e0 into rust-lang:master Nov 8, 2023
20 checks passed
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 10, 2023
Update cargo

12 commits in 7046d992f9f32ba209a8079f662ebccf9da8de25..6790a5127895debec95c24aefaeb18e059270df3
2023-11-08 03:24:57 +0000 to 2023-11-10 17:09:35 +0000
- refactor(source): Prepare for new PackageIDSpec syntax (rust-lang/cargo#12938)
- credential: include license files in all published crates (rust-lang/cargo#12953)
- fix: preserve jobserver file descriptors on rustc invocation in `fix_exec_rustc` (rust-lang/cargo#12951)
- refactor(resolver): Consolidate logic in `VersionPreferences` (rust-lang/cargo#12930)
- refactor(toml): Simplify code to make schema split easier (rust-lang/cargo#12948)
- Filter `cargo-credential-*` dependencies by OS (rust-lang/cargo#12949)
- refactor(util): Pull out `mod util_semver` (rust-lang/cargo#12940)
- Fix the invalidate feature name message (rust-lang/cargo#12939)
- refactor(util): Prepare for splitting out semver logic (rust-lang/cargo#12926)
- feat: Make browser links out of HTML file paths (rust-lang/cargo#12889)
- Do not allow empty feature name (rust-lang/cargo#12928)
- fix(timings): unnecessary backslash when error happens (rust-lang/cargo#12934)

r? ghost
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 11, 2023
Update cargo

12 commits in 7046d992f9f32ba209a8079f662ebccf9da8de25..6790a5127895debec95c24aefaeb18e059270df3
2023-11-08 03:24:57 +0000 to 2023-11-10 17:09:35 +0000
- refactor(source): Prepare for new PackageIDSpec syntax (rust-lang/cargo#12938)
- credential: include license files in all published crates (rust-lang/cargo#12953)
- fix: preserve jobserver file descriptors on rustc invocation in `fix_exec_rustc` (rust-lang/cargo#12951)
- refactor(resolver): Consolidate logic in `VersionPreferences` (rust-lang/cargo#12930)
- refactor(toml): Simplify code to make schema split easier (rust-lang/cargo#12948)
- Filter `cargo-credential-*` dependencies by OS (rust-lang/cargo#12949)
- refactor(util): Pull out `mod util_semver` (rust-lang/cargo#12940)
- Fix the invalidate feature name message (rust-lang/cargo#12939)
- refactor(util): Prepare for splitting out semver logic (rust-lang/cargo#12926)
- feat: Make browser links out of HTML file paths (rust-lang/cargo#12889)
- Do not allow empty feature name (rust-lang/cargo#12928)
- fix(timings): unnecessary backslash when error happens (rust-lang/cargo#12934)

r? ghost
@ehuss ehuss added this to the 1.75.0 milestone Dec 6, 2023
epage added a commit to epage/cargo that referenced this pull request Dec 13, 2023
This was allowed when switching from `toml` v0.5 to `toml_edit` which
started allowing empty keys when parsing TOML.
This mirrors the change
we made for disallowing empty feature names in rust-lang#12928.
epage added a commit to epage/cargo that referenced this pull request Dec 13, 2023
This was allowed when switching from `toml` v0.5 to `toml_edit` which
started allowing empty keys when parsing TOML.
This mirrors the change
we made for disallowing empty feature names in rust-lang#12928.
bors added a commit that referenced this pull request Dec 13, 2023
fix: Fill in more empty name holes

### What does this PR try to resolve?

This is a follow up to #13152 and expands on work done in #12928.

This is also part of #12801 as I am refactoring how we do validation so that it parts of it can move into the schema, removing the last dependency the schema has on the rest of cargo.

### How should we test and review this PR?

This prevents empty registry names which should be fine for the same reason as preventing empty feature names in #12928, that this was a regression due to changes in toml parsers

### Additional information
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants