fix: make event loop in tray compatible with main window
This commit is contained in:
@@ -969,13 +969,20 @@ impl PeerConfig {
|
||||
|
||||
fn path(id: &str) -> PathBuf {
|
||||
//If the id contains invalid chars, encode it
|
||||
let forbidden_paths = Regex::new(r".*[<>:/\\|\?\*].*").unwrap();
|
||||
let id_encoded = if forbidden_paths.is_match(id) {
|
||||
"base64_".to_string() + base64::encode(id, base64::Variant::Original).as_str()
|
||||
let forbidden_paths = Regex::new(r".*[<>:/\\|\?\*].*");
|
||||
let path: PathBuf;
|
||||
if let Ok(forbidden_paths) = forbidden_paths {
|
||||
let id_encoded = if forbidden_paths.is_match(id) {
|
||||
"base64_".to_string() + base64::encode(id, base64::Variant::Original).as_str()
|
||||
} else {
|
||||
id.to_string()
|
||||
};
|
||||
path = [PEERS, id_encoded.as_str()].iter().collect();
|
||||
} else {
|
||||
id.to_string()
|
||||
};
|
||||
let path: PathBuf = [PEERS, id_encoded.as_str()].iter().collect();
|
||||
log::warn!("Regex create failed: {:?}", forbidden_paths.err());
|
||||
// fallback for failing to create this regex.
|
||||
path = [PEERS, id.replace(":", "_").as_str()].iter().collect();
|
||||
}
|
||||
Config::with_extension(Config::path(path))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user