diff --git a/src/custom_server.rs b/src/custom_server.rs index 3a7d60fe9..44e80658c 100644 --- a/src/custom_server.rs +++ b/src/custom_server.rs @@ -62,7 +62,7 @@ pub fn get_custom_server_from_string(s: &str) -> ResultType { * This allows using a ',' (comma) symbol as a final delimiter. */ if s.to_lowercase().contains("host=") { - let stripped = &s[s.to_lowercase().find("host=").unwrap_or(0)..s.len()]; + let stripped = &s[s.to_ascii_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(); @@ -232,4 +232,21 @@ mod test { get_custom_server_from_string("=0nI900VsFHZVBVdIlncwpHS4V0bOZ0dtVldrpVO4JHdCp0YV5WdzUGZzdnYRVjI6ISeltmIsISMuEjLx4SMiojI0N3boJye.exe") .unwrap(), lic); } + + #[test] + fn test_filename_license_string_in_non_ascii_path() { + // Windows passes the full exe path, and `İ` grows from 2 to 3 bytes when lowercased. + assert_eq!( + get_custom_server_from_string( + r"C:\Users\İsmail\Downloads\rustdesk-host=server.example.net,key=Zm9vYmFyLiwyCg==.exe" + ) + .unwrap(), + CustomServer { + host: "server.example.net".to_owned(), + key: "Zm9vYmFyLiwyCg==".to_owned(), + api: "".to_owned(), + relay: "".to_owned(), + } + ); + } }