From f8bf90421acce2c05ffedcee8e9b07f9adb96295 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 14 Jan 2026 07:43:18 +0000 Subject: Improve placeholder check to verify both opening and closing delimiters Co-authored-by: HsiangNianian <44714368+HsiangNianian@users.noreply.github.com> --- src-tauri/src/main.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index c2fd098..3a5f8a5 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -40,6 +40,20 @@ impl MsRefreshTokenState { } } +/// Check if a string contains unresolved placeholders in the form ${...} +fn has_unresolved_placeholder(s: &str) -> bool { + if let Some(start_pos) = s.find("${") { + // Check if there's a closing brace after the opening + if let Some(end_pos) = s[start_pos..].find('}') { + // Verify the closing brace is after the opening sequence + return end_pos > 2; // "${" is 2 chars, so } must be after position 2 + } + // Found opening but no closing brace - treat as unresolved + return true; + } + false +} + #[tauri::command] async fn start_game( window: Window, @@ -450,7 +464,7 @@ async fn start_game( arg = arg.replace(key, replacement); } // Skip arguments with unresolved placeholders - if !arg.contains("${") { + if !has_unresolved_placeholder(&arg) { args.push(arg); } } else if let Some(arr) = val.as_array() { @@ -461,7 +475,7 @@ async fn start_game( arg = arg.replace(key, replacement); } // Skip arguments with unresolved placeholders - if !arg.contains("${") { + if !has_unresolved_placeholder(&arg) { args.push(arg); } } -- cgit v1.2.3-70-g09d2