From 9b59469cfe0a46d127efd640142da249dafceec5 Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Wed, 14 Jan 2026 15:34:55 +0800 Subject: fix: prevent feature-based rules from being applied in library checks --- src-tauri/src/core/game_version.rs | 1 + src-tauri/src/core/rules.rs | 7 +++++++ 2 files changed, 8 insertions(+) (limited to 'src-tauri/src') diff --git a/src-tauri/src/core/game_version.rs b/src-tauri/src/core/game_version.rs index 572882f..31477a9 100644 --- a/src-tauri/src/core/game_version.rs +++ b/src-tauri/src/core/game_version.rs @@ -52,6 +52,7 @@ pub struct Library { pub struct Rule { pub action: String, // "allow" or "disallow" pub os: Option, + pub features: Option, // Feature-based rules (e.g., is_demo_user, has_quick_plays_support) } #[derive(Debug, Deserialize)] diff --git a/src-tauri/src/core/rules.rs b/src-tauri/src/core/rules.rs index 877982a..71abda5 100644 --- a/src-tauri/src/core/rules.rs +++ b/src-tauri/src/core/rules.rs @@ -47,6 +47,13 @@ pub fn is_library_allowed(rules: &Option>) -> bool { } fn rule_matches(rule: &Rule) -> bool { + // Feature-based rules (e.g., is_demo_user, has_quick_plays_support, is_quick_play_singleplayer) + // are not implemented in this launcher, so we return false for any rule that has features. + // This prevents adding arguments like --demo, --quickPlayPath, --quickPlaySingleplayer, etc. + if rule.features.is_some() { + return false; + } + match &rule.os { None => true, // No OS condition means it applies to all Some(os_rule) => { -- cgit v1.2.3-70-g09d2 From 30036f1e0eda71242a5b0f6823803fd84ca075af Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Wed, 14 Jan 2026 15:35:00 +0800 Subject: fix: skip unresolved placeholders in game start arguments --- src-tauri/src/main.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src-tauri/src') diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index ae74a03..c2fd098 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -449,7 +449,10 @@ async fn start_game( for (key, replacement) in &replacements { arg = arg.replace(key, replacement); } - args.push(arg); + // Skip arguments with unresolved placeholders + if !arg.contains("${") { + args.push(arg); + } } else if let Some(arr) = val.as_array() { for sub in arr { if let Some(s) = sub.as_str() { @@ -457,7 +460,10 @@ async fn start_game( for (key, replacement) in &replacements { arg = arg.replace(key, replacement); } - args.push(arg); + // Skip arguments with unresolved placeholders + if !arg.contains("${") { + args.push(arg); + } } } } -- cgit v1.2.3-70-g09d2 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(-) (limited to 'src-tauri/src') 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 From 4843a4fc5e4f97790aba1fa5cc3b4ad5ac55c220 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 14 Jan 2026 07:46:00 +0000 Subject: Add documentation to clarify placeholder detection logic Co-authored-by: HsiangNianian <44714368+HsiangNianian@users.noreply.github.com> --- src-tauri/src/main.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src-tauri/src') diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 3a5f8a5..a24510e 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -41,16 +41,23 @@ impl MsRefreshTokenState { } /// Check if a string contains unresolved placeholders in the form ${...} +/// +/// After the replacement phase, if a string still contains ${...}, it means +/// that placeholder variable was not found in the replacements map and is +/// therefore unresolved. We should skip adding such arguments to avoid +/// passing malformed arguments to the game launcher. fn has_unresolved_placeholder(s: &str) -> bool { + // Look for the opening sequence 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 + // Check if there's a closing brace after the opening sequence + if s[start_pos + 2..].find('}').is_some() { + // Found a complete ${...} pattern - this is an unresolved placeholder + return true; } - // Found opening but no closing brace - treat as unresolved + // Found ${ but no closing } - also treat as unresolved/malformed return true; } + // No ${ found - the string is fully resolved false } -- cgit v1.2.3-70-g09d2