修复 Direct MCP 路径文案泄露
Project CI / Repository checks (pull_request) Successful in 4m24s
Project CI / Frontend tests (pull_request) Successful in 4m46s
Project CI / Backend tests (pull_request) Successful in 7m44s
Project CI / Native shell tests (pull_request) Failing after 13m40s

平台无关拒绝盘符、绝对路径和上级目录

避免未审核路径出现在 Direct Codex 活动文案中
This commit is contained in:
2026-09-03 21:42:39 +08:00
parent 75da77dcb4
commit d0d3466a56
@@ -596,15 +596,29 @@ fn direct_codex_project_path_detail(item: &serde_json::Value, pointer: &str) ->
if value.is_empty() {
return None;
}
let trimmed = value.trim();
let has_windows_drive_prefix = trimmed.len() >= 2
&& trimmed.as_bytes()[0].is_ascii_alphabetic()
&& trimmed.as_bytes()[1] == b':';
let has_absolute_prefix = trimmed.starts_with('/')
|| trimmed.starts_with('\\')
|| trimmed.starts_with("//")
|| trimmed.starts_with("\\\\");
let has_parent_segment = trimmed
.split(['/', '\\'])
.any(|component| component == "..");
let path = std::path::Path::new(value);
if path.is_absolute()
|| has_windows_drive_prefix
|| has_absolute_prefix
|| has_parent_segment
|| path
.components()
.any(|component| matches!(component, std::path::Component::ParentDir))
{
return None;
}
direct_codex_bounded_detail(value, 120)
direct_codex_bounded_detail(trimmed, 120)
}
fn direct_codex_mcp_tool_intermediate_text(item: &serde_json::Value) -> String {