mirror of
https://github.com/openai/codex.git
synced 2026-09-08 15:50:34 +00:00
Merge 7c5158eb5b into sapling-pr-archive-bolinfest
This commit is contained in:
@@ -383,6 +383,16 @@ fn validate_glob_scan_max_depth(max_depth: Option<usize>) -> io::Result<Option<u
|
||||
}
|
||||
|
||||
fn contains_glob_chars(path: &str) -> bool {
|
||||
contains_glob_chars_for_platform(path, cfg!(windows))
|
||||
}
|
||||
|
||||
fn contains_glob_chars_for_platform(path: &str, is_windows: bool) -> bool {
|
||||
let normalized_windows_path = if is_windows {
|
||||
normalize_windows_device_path(path)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let path = normalized_windows_path.as_deref().unwrap_or(path);
|
||||
path.chars().any(|ch| matches!(ch, '*' | '?' | '[' | ']'))
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,18 @@ fn normalize_absolute_path_for_platform_simplifies_windows_verbatim_paths() {
|
||||
assert_eq!(parsed, PathBuf::from(r"D:\c\x\worktrees\2508\swift-base"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn windows_verbatim_path_prefix_does_not_count_as_glob_syntax() {
|
||||
assert!(!contains_glob_chars_for_platform(
|
||||
r"\\?\D:\c\x\worktrees\2508\swift-base",
|
||||
/*is_windows*/ true,
|
||||
));
|
||||
assert!(contains_glob_chars_for_platform(
|
||||
r"\\?\D:\c\x\worktrees\2508\**\*.env",
|
||||
/*is_windows*/ true,
|
||||
));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn restricted_read_implicitly_allows_helper_executables() -> std::io::Result<()> {
|
||||
let temp_dir = TempDir::new()?;
|
||||
|
||||
Reference in New Issue
Block a user