Skip to content

Commit f324360

Browse files
leno23cursoragent
andcommitted
test(windows): cover \\?\ extended-length path normalization
Explicitly treat Win32 `\\?\` prefixes when normalizing `/` for cmd.exe, and add unit tests for forward- and backslash forms. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 25916a0 commit f324360

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/util/windows_cmd.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ fn should_normalize_path_token(token: &str) -> bool {
103103
}
104104
}
105105

106+
// Win32 extended-length paths (`\\?\` prefix) may use `/` in user input.
107+
if token.starts_with(r"\\?\") && token.contains('/') {
108+
return true;
109+
}
110+
106111
has_windows_executable_extension(token)
107112
}
108113

@@ -164,6 +169,22 @@ mod tests {
164169
assert_eq!(normalize_command_line_for_cmd_impl(command), command);
165170
}
166171

172+
#[test]
173+
fn normalizes_extended_length_path_prefix() {
174+
assert_eq!(
175+
normalize_command_line_for_cmd_impl(
176+
r"\\?\C:/Users/foo/very/long/path/to/tool.exe"
177+
),
178+
r"\\?\C:\Users\foo\very\long\path\to\tool.exe"
179+
);
180+
}
181+
182+
#[test]
183+
fn leaves_extended_length_path_with_backslashes_unchanged() {
184+
let command = r"\\?\C:\Users\foo\tool.exe";
185+
assert_eq!(normalize_command_line_for_cmd_impl(command), command);
186+
}
187+
167188
#[test]
168189
fn split_command_line_respects_double_quotes() {
169190
assert_eq!(

0 commit comments

Comments
 (0)