Repository navigation
fix: support Windows path completion - #7
Conversation
Reviewer's GuideImplementationSplit completion paths using both slash styles on Windows while retaining slash-only parsing elsewhere, and route
TestsAdd regression coverage for Unix paths, Windows drive paths, and mixed separators.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
There was a problem hiding this comment.
Hey - I've found 4 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/util.rs" line_range="394" />
<code_context>
/// reads are not free.
+fn split_completion_path(input: &str, windows: bool) -> (&str, &str) {
+ let separator = if windows {
+ input.rfind(['/', '\\'])
+ } else {
+ input.rfind('/')
</code_context>
<issue_to_address>
**Backslash UNC input initiates SMB access**
When a Windows user types or pastes an attacker-provided `\\host\share\...` path into the input, `split_completion_path` treats the backslashes as directory separators, and `update_completion` immediately passes the resulting directory to `read_dir`; Windows attempts SMB authentication using the user's ambient credentials before the user accepts the candidate.
Avoid automatically enumerating UNC paths while the user types; require a deliberate action before accessing a remote share.
</issue_to_address>
### Comment 2
<location path="src/util.rs" line_range="394" />
<code_context>
/// reads are not free.
+fn split_completion_path(input: &str, windows: bool) -> (&str, &str) {
+ let separator = if windows {
+ input.rfind(['/', '\\'])
+ } else {
+ input.rfind('/')
</code_context>
<issue_to_address>
**Drive-relative suggestions are missing**
When a Windows user enters a drive-relative path such as `C:rec` with no separator, `split_completion_path` returns an empty directory and keeps the drive-qualified text as the filename prefix, so `complete_path` scans the process’s current directory and returns no useful suggestions; accepted suggestions also resolve from the wrong directory.
Handle the drive prefix as the directory for drive-relative paths in `split_completion_path`.
Also at `src/util.rs:400-401`.
</issue_to_address>
### Comment 3
<location path="src/util.rs" line_range="394" />
<code_context>
/// reads are not free.
+fn split_completion_path(input: &str, windows: bool) -> (&str, &str) {
+ let separator = if windows {
+ input.rfind(['/', '\\'])
+ } else {
+ input.rfind('/')
</code_context>
<issue_to_address>
**Backslash home paths return no candidates**
When a Windows user enters a home-relative path using `~\`, `expand_tilde` leaves the backslash form unchanged, so `complete_path` scans a literal `~\` path and returns no candidates.
Expand tilde paths using Windows backslashes as well as forward slashes.
</issue_to_address>
### Comment 4
<location path="src/util.rs" line_range="831-833" />
<code_context>
+ ("/home/user/", "rec")
+ );
+ assert_eq!(
+ split_completion_path("C:\\Users\\user\\rec", true),
+ ("C:\\Users\\user\\", "rec")
+ );
+ assert_eq!(
+ split_completion_path("C:/Users/user/rec", true),
</code_context>
<issue_to_address>
**Windows wiring regression goes undetected**
When `complete_path` is wired to use the non-Windows separator mode, `completion_path_splits_native_and_windows_separators` calls `split_completion_path` directly with `true`, so it passes even if `complete_path` stops enabling Windows separators and Windows path completion remains broken.
Add a test that exercises `complete_path` with a Windows-style path and verifies the resulting directory and candidates.
</issue_to_address>Sourcery assessment
Approval pending. 4 findings to address first.
Blocking findings: src/util.rs:394, src/util.rs:394, src/util.rs:394, src/util.rs:833
| /// reads are not free. | ||
| fn split_completion_path(input: &str, windows: bool) -> (&str, &str) { | ||
| let separator = if windows { | ||
| input.rfind(['/', '\\']) |
There was a problem hiding this comment.
🟡 Medium · Backslash UNC input initiates SMB access
When a Windows user types or pastes an attacker-provided \\host\share\... path into the input, split_completion_path treats the backslashes as directory separators, and update_completion immediately passes the resulting directory to read_dir; Windows attempts SMB authentication using the user's ambient credentials before the user accepts the candidate.
Avoid automatically enumerating UNC paths while the user types; require a deliberate action before accessing a remote share.
Prompt for AI agents
In `src/util.rs` at line 394:
**Backslash UNC input initiates SMB access**
When a Windows user types or pastes an attacker-provided `\\host\share\...` path into the input, `split_completion_path` treats the backslashes as directory separators, and `update_completion` immediately passes the resulting directory to `read_dir`; Windows attempts SMB authentication using the user's ambient credentials before the user accepts the candidate.
Avoid automatically enumerating UNC paths while the user types; require a deliberate action before accessing a remote share.| /// reads are not free. | ||
| fn split_completion_path(input: &str, windows: bool) -> (&str, &str) { | ||
| let separator = if windows { | ||
| input.rfind(['/', '\\']) |
There was a problem hiding this comment.
🟡 Medium · Drive-relative suggestions are missing
When a Windows user enters a drive-relative path such as C:rec with no separator, split_completion_path returns an empty directory and keeps the drive-qualified text as the filename prefix, so complete_path scans the process’s current directory and returns no useful suggestions; accepted suggestions also resolve from the wrong directory.
Handle the drive prefix as the directory for drive-relative paths in split_completion_path.
Also at src/util.rs:400-401.
Prompt for AI agents
In `src/util.rs` at line 394:
**Drive-relative suggestions are missing**
When a Windows user enters a drive-relative path such as `C:rec` with no separator, `split_completion_path` returns an empty directory and keeps the drive-qualified text as the filename prefix, so `complete_path` scans the process’s current directory and returns no useful suggestions; accepted suggestions also resolve from the wrong directory.
Handle the drive prefix as the directory for drive-relative paths in `split_completion_path`.
Also at `src/util.rs:400-401`.| /// reads are not free. | ||
| fn split_completion_path(input: &str, windows: bool) -> (&str, &str) { | ||
| let separator = if windows { | ||
| input.rfind(['/', '\\']) |
There was a problem hiding this comment.
🟡 Medium · Backslash home paths return no candidates
When a Windows user enters a home-relative path using ~\, expand_tilde leaves the backslash form unchanged, so complete_path scans a literal ~\ path and returns no candidates.
Expand tilde paths using Windows backslashes as well as forward slashes.
Prompt for AI agents
In `src/util.rs` at line 394:
**Backslash home paths return no candidates**
When a Windows user enters a home-relative path using `~\`, `expand_tilde` leaves the backslash form unchanged, so `complete_path` scans a literal `~\` path and returns no candidates.
Expand tilde paths using Windows backslashes as well as forward slashes.| split_completion_path("C:\\Users\\user\\rec", true), | ||
| ("C:\\Users\\user\\", "rec") | ||
| ); |
There was a problem hiding this comment.
🟡 Medium · Windows wiring regression goes undetected
When complete_path is wired to use the non-Windows separator mode, completion_path_splits_native_and_windows_separators calls split_completion_path directly with true, so it passes even if complete_path stops enabling Windows separators and Windows path completion remains broken.
Add a test that exercises complete_path with a Windows-style path and verifies the resulting directory and candidates.
Prompt for AI agents
In `src/util.rs` at lines 831-833:
**Windows wiring regression goes undetected**
When `complete_path` is wired to use the non-Windows separator mode, `completion_path_splits_native_and_windows_separators` calls `split_completion_path` directly with `true`, so it passes even if `complete_path` stops enabling Windows separators and Windows path completion remains broken.
Add a test that exercises `complete_path` with a Windows-style path and verifies the resulting directory and candidates.
Summary
Verification
Summary by Sourcery
Fix cross-platform path splitting so completion correctly handles Windows paths without changing Unix behavior.
Bug Fixes:
Enhancements:
Tests: