From bc211c8031ac3b9b39ab14820ac1d8d064c84580 Mon Sep 17 00:00:00 2001 From: 21pages Date: Wed, 20 Nov 2024 19:44:24 +0800 Subject: [PATCH] A=b, A case insensitive (#9976) Signed-off-by: 21pages --- flutter/lib/common.dart | 12 ++++++++---- flutter/pubspec.lock | 8 ++++---- flutter/pubspec.yaml | 2 +- src/client.rs | 10 +++++----- src/custom_server.rs | 25 +++++++++++++++++++------ 5 files changed, 37 insertions(+), 20 deletions(-) diff --git a/flutter/lib/common.dart b/flutter/lib/common.dart index 71e7f68d3..fb389b45e 100644 --- a/flutter/lib/common.dart +++ b/flutter/lib/common.dart @@ -2245,7 +2245,10 @@ List? urlLinkToCmdArgs(Uri uri) { } } - var key = uri.queryParameters["key"]; + var queryParameters = + uri.queryParameters.map((k, v) => MapEntry(k.toLowerCase(), v)); + + var key = queryParameters["key"]; if (id != null) { if (key != null) { id = "$id?key=$key"; @@ -2254,7 +2257,7 @@ List? urlLinkToCmdArgs(Uri uri) { if (isMobile) { if (id != null) { - final forceRelay = uri.queryParameters["relay"] != null; + final forceRelay = queryParameters["relay"] != null; connect(Get.context!, id, forceRelay: forceRelay); return null; } @@ -2264,7 +2267,7 @@ List? urlLinkToCmdArgs(Uri uri) { if (command != null && id != null) { args.add(command); args.add(id); - var param = uri.queryParameters; + var param = queryParameters; String? password = param["password"]; if (password != null) args.addAll(['--password', password]); String? switch_uuid = param["switch_uuid"]; @@ -2510,7 +2513,8 @@ Future onActiveWindowChanged() async { // embedder.cc (2672): 'FlutterEngineSendPlatformMessage' returned 'kInvalidArguments'. Invalid engine handle. // 2024-11-11 11:41:11.565 RustDesk[90272:2567686] Failed to send message to Flutter engine on channel 'flutter/lifecycle' (2). // ``` - periodic_immediate(Duration(milliseconds: 30), RdPlatformChannel.instance.terminate); + periodic_immediate( + Duration(milliseconds: 30), RdPlatformChannel.instance.terminate); } } } diff --git a/flutter/pubspec.lock b/flutter/pubspec.lock index 4010edf97..7c60e037a 100644 --- a/flutter/pubspec.lock +++ b/flutter/pubspec.lock @@ -745,10 +745,10 @@ packages: dependency: "direct main" description: name: image_picker - sha256: b6951e25b795d053a6ba03af5f710069c99349de9341af95155d52665cb4607c + sha256: "021834d9c0c3de46bf0fe40341fa07168407f694d9b2bb18d532dc1261867f7a" url: "https://pub.dev" source: hosted - version: "0.8.9" + version: "1.1.2" image_picker_android: dependency: transitive description: @@ -793,10 +793,10 @@ packages: dependency: transitive description: name: image_picker_platform_interface - sha256: fa4e815e6fcada50e35718727d83ba1c92f1edf95c0b4436554cec301b56233b + sha256: "9ec26d410ff46f483c5519c29c02ef0e02e13a543f882b152d4bfd2f06802f80" url: "https://pub.dev" source: hosted - version: "2.9.3" + version: "2.10.0" image_picker_windows: dependency: transitive description: diff --git a/flutter/pubspec.yaml b/flutter/pubspec.yaml index 1855aebec..afe09a0dc 100644 --- a/flutter/pubspec.yaml +++ b/flutter/pubspec.yaml @@ -46,7 +46,7 @@ dependencies: http: ^1.1.0 qr_code_scanner: ^1.0.0 zxing2: ^0.2.0 - image_picker: ^0.8.5 + image_picker: ^1.1.2 image: ^4.0.17 back_button_interceptor: ^6.0.1 flutter_rust_bridge: "1.80.1" diff --git a/src/client.rs b/src/client.rs index 18c3d268b..503870cc1 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1408,18 +1408,18 @@ impl LoginConfigHandler { let server = server_key.next().unwrap_or_default(); let args = server_key.next().unwrap_or_default(); let key = if server == PUBLIC_SERVER { - PUBLIC_RS_PUB_KEY + PUBLIC_RS_PUB_KEY.to_owned() } else { - let mut args_map: HashMap<&str, &str> = HashMap::new(); + let mut args_map: HashMap = HashMap::new(); for arg in args.split('&') { if let Some(kv) = arg.find('=') { - let k = &arg[0..kv]; + let k = arg[0..kv].to_lowercase(); let v = &arg[kv + 1..]; args_map.insert(k, v); } } let key = args_map.remove("key").unwrap_or_default(); - key + key.to_owned() }; // here we can check /r@server @@ -1427,7 +1427,7 @@ impl LoginConfigHandler { if real_id != raw_id { force_relay = true; } - self.other_server = Some((real_id.clone(), server.to_owned(), key.to_owned())); + self.other_server = Some((real_id.clone(), server.to_owned(), key)); id = format!("{real_id}@{server}"); } else { let real_id = crate::ui_interface::handle_relay_id(&id); diff --git a/src/custom_server.rs b/src/custom_server.rs index c2c5e7f63..18118788e 100644 --- a/src/custom_server.rs +++ b/src/custom_server.rs @@ -56,8 +56,8 @@ pub fn get_custom_server_from_string(s: &str) -> ResultType { * * This allows using a ',' (comma) symbol as a final delimiter. */ - if s.contains("host=") { - let stripped = &s[s.find("host=").unwrap_or(0)..s.len()]; + if s.to_lowercase().contains("host=") { + let stripped = &s[s.to_lowercase().find("host=").unwrap_or(0)..s.len()]; let strs: Vec<&str> = stripped.split(",").collect(); let mut host = String::default(); let mut key = String::default(); @@ -65,16 +65,17 @@ pub fn get_custom_server_from_string(s: &str) -> ResultType { let mut relay = String::default(); let strs_iter = strs.iter(); for el in strs_iter { - if el.starts_with("host=") { + let el_lower = el.to_lowercase(); + if el_lower.starts_with("host=") { host = el.chars().skip(5).collect(); } - if el.starts_with("key=") { + if el_lower.starts_with("key=") { key = el.chars().skip(4).collect(); } - if el.starts_with("api=") { + if el_lower.starts_with("api=") { api = el.chars().skip(4).collect(); } - if el.starts_with("relay=") { + if el_lower.starts_with("relay=") { relay = el.chars().skip(6).collect(); } } @@ -169,6 +170,18 @@ mod test { relay: "server.example.net".to_owned(), } ); + assert_eq!( + get_custom_server_from_string( + "rustdesk-Host=server.example.net,Key=Zm9vYmFyLiwyCg==,RELAY=server.example.net.exe" + ) + .unwrap(), + CustomServer { + host: "server.example.net".to_owned(), + key: "Zm9vYmFyLiwyCg==".to_owned(), + api: "".to_owned(), + relay: "server.example.net".to_owned(), + } + ); let lic = CustomServer { host: "1.1.1.1".to_owned(), key: "5Qbwsde3unUcJBtrx9ZkvUmwFNoExHzpryHuPUdqlWM=".to_owned(),