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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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
ChrisDenton added a commit to ChrisDenton/rust that referenced this pull request Apr 23, 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`
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
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