diff --git a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/binding.rs b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/binding.rs index d6eb3ba8d..797f8c44d 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/binding.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/binding.rs @@ -183,8 +183,7 @@ fn validate_binding_response_shape( .is_some_and(serde_json::Value::is_object); if !valid_component { return Err( - "组件绑定 change 的 component 必须是 PureNode 或 WithComponent 对象" - .to_string(), + "组件绑定 change 的 component 必须是 PureNode 或 WithComponent 对象".to_string(), ); } } diff --git a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/workflow/mod.rs b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/workflow/mod.rs index b145d8e9b..62dae2474 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/workflow/mod.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/workflow/mod.rs @@ -187,7 +187,18 @@ pub(crate) async fn separate_ui_impl( extracted_area, } = decision { - let cut_path = sidecar.join(format!("cut-{}.png", to_node.as_str())); + let node_id = to_node.as_str(); + if !node_id.chars().all(|character| { + character.is_ascii_alphanumeric() || matches!(character, '-' | '_') + }) { + cut_error = Some(format!("节点 {} 的名称包含非法路径字符", node_id)); + break; + } + let cut_path = sidecar.join(format!("cut-{node_id}.png")); + if !cut_path.starts_with(&sidecar) { + cut_error = Some(format!("节点 {} 的路径越界", node_id)); + break; + } match cut::cut_processed_image( processed_path.clone(), *extracted_area, @@ -200,9 +211,8 @@ pub(crate) async fn separate_ui_impl( .insert(to_node.clone(), project_relative_path(root, &cut_path)?); } Err(error) => { - app_log!("ui_separation.error stage=cut_image tree_index={} batch_index={} node_id={} error={error}", tree_index, batch_index, to_node.as_str()); - cut_error = - Some(format!("节点 {} 的分离区域无效:{error}", to_node.as_str())); + app_log!("ui_separation.error stage=cut_image tree_index={} batch_index={} node_id={} error={error}", tree_index, batch_index, node_id); + cut_error = Some(format!("节点 {} 的分离区域无效:{error}", node_id)); break; } }