Skip to content

Validate extension in PathBuf::add_extension #140163

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

Merged
merged 1 commit into from
Apr 23, 2025

Conversation

thaliaarchi
Copy link
Contributor

@thaliaarchi thaliaarchi commented Apr 22, 2025

The extension is validated in PathBuf::set_extension, but not add_extension. Fix that. Check for both / and \ path separators on Windows, even when the path is verbatim, since this is logically like PathBuf::push which normalizes separators (i.e., keeping the current behavior).

PathBuf::add_extension is tracked in #127292.

r? @ChrisDenton

The extension is validated in `PathBuf::set_extension`, but not
`add_extension`. Fix that. Check for both / and \ path separators on
Windows, even when the path is verbatim, since this is logically like
`PathBuf::push` which normalizes separators (i.e., keeping the current
behavior).
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 22, 2025
@ChrisDenton
Copy link
Member

It definitely makes sense for the unstable add_extension to be consistent with the stable set_extension. Thanks!

@ChrisDenton
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Apr 22, 2025

📌 Commit 006b7e3 has been approved by ChrisDenton

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 Apr 22, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 23, 2025
…enton

Rollup of 7 pull requests

Successful merges:

 - rust-lang#140142 (Some more graphviz tweaks)
 - rust-lang#140146 (Update `compiler_builtins` to 0.1.156)
 - rust-lang#140147 (Clean: rename `open_braces` to `open_delimiters` in lexer and move `make_unclosed_delims_error` into `diagnostics.rs`.)
 - rust-lang#140160 (Use `is_lang_item` and `as_lang_item` instead of handrolling their logic)
 - rust-lang#140163 (Validate extension in `PathBuf::add_extension`)
 - rust-lang#140173 (Ping Mara when touching format_args!() internals.)
 - rust-lang#140175 (`rc""` more clear error message)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 23, 2025
…enton

Rollup of 7 pull requests

Successful merges:

 - rust-lang#140142 (Some more graphviz tweaks)
 - rust-lang#140146 (Update `compiler_builtins` to 0.1.156)
 - rust-lang#140147 (Clean: rename `open_braces` to `open_delimiters` in lexer and move `make_unclosed_delims_error` into `diagnostics.rs`.)
 - rust-lang#140160 (Use `is_lang_item` and `as_lang_item` instead of handrolling their logic)
 - rust-lang#140163 (Validate extension in `PathBuf::add_extension`)
 - rust-lang#140173 (Ping Mara when touching format_args!() internals.)
 - rust-lang#140175 (`rc""` more clear error message)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 23, 2025
…enton

Rollup of 7 pull requests

Successful merges:

 - rust-lang#140142 (Some more graphviz tweaks)
 - rust-lang#140146 (Update `compiler_builtins` to 0.1.156)
 - rust-lang#140147 (Clean: rename `open_braces` to `open_delimiters` in lexer and move `make_unclosed_delims_error` into `diagnostics.rs`.)
 - rust-lang#140160 (Use `is_lang_item` and `as_lang_item` instead of handrolling their logic)
 - rust-lang#140163 (Validate extension in `PathBuf::add_extension`)
 - rust-lang#140173 (Ping Mara when touching format_args!() internals.)
 - rust-lang#140175 (`rc""` more clear error message)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 23, 2025
…enton

Rollup of 7 pull requests

Successful merges:

 - rust-lang#140142 (Some more graphviz tweaks)
 - rust-lang#140146 (Update `compiler_builtins` to 0.1.156)
 - rust-lang#140147 (Clean: rename `open_braces` to `open_delimiters` in lexer and move `make_unclosed_delims_error` into `diagnostics.rs`.)
 - rust-lang#140160 (Use `is_lang_item` and `as_lang_item` instead of handrolling their logic)
 - rust-lang#140163 (Validate extension in `PathBuf::add_extension`)
 - rust-lang#140173 (Ping Mara when touching format_args!() internals.)
 - rust-lang#140175 (`rc""` more clear error message)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit ed4e167 into rust-lang:master Apr 23, 2025
6 checks passed
@rustbot rustbot added this to the 1.88.0 milestone Apr 23, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Apr 23, 2025
Rollup merge of rust-lang#140163 - thaliaarchi:pathbuf-validate-extension, r=ChrisDenton

Validate extension in `PathBuf::add_extension`

The extension is validated in `PathBuf::set_extension`, but not `add_extension`. Fix that. Check for both `/` and `\` path separators on Windows, even when the path is verbatim, since this is logically like `PathBuf::push` which normalizes separators (i.e., keeping the current behavior).

`PathBuf::add_extension` is tracked in rust-lang#127292.

r? `@ChrisDenton`
@thaliaarchi thaliaarchi deleted the pathbuf-validate-extension branch April 23, 2025 18:48
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request Apr 24, 2025
…sion, r=ChrisDenton

Validate extension in `PathBuf::add_extension`

The extension is validated in `PathBuf::set_extension`, but not `add_extension`. Fix that. Check for both `/` and `\` path separators on Windows, even when the path is verbatim, since this is logically like `PathBuf::push` which normalizes separators (i.e., keeping the current behavior).

`PathBuf::add_extension` is tracked in rust-lang#127292.

r? `@ChrisDenton`
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request Apr 24, 2025
…enton

Rollup of 7 pull requests

Successful merges:

 - rust-lang#140142 (Some more graphviz tweaks)
 - rust-lang#140146 (Update `compiler_builtins` to 0.1.156)
 - rust-lang#140147 (Clean: rename `open_braces` to `open_delimiters` in lexer and move `make_unclosed_delims_error` into `diagnostics.rs`.)
 - rust-lang#140160 (Use `is_lang_item` and `as_lang_item` instead of handrolling their logic)
 - rust-lang#140163 (Validate extension in `PathBuf::add_extension`)
 - rust-lang#140173 (Ping Mara when touching format_args!() internals.)
 - rust-lang#140175 (`rc""` more clear error message)

r? `@ghost`
`@rustbot` modify labels: rollup
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. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants