From 5504994cb92f8b15f88241d9e0a262656c57b92e Mon Sep 17 00:00:00 2001 From: GyDi Date: Fri, 28 Oct 2022 13:00:52 +0800 Subject: [PATCH] feat: check remote profile field --- src-tauri/src/data/prfitem.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/data/prfitem.rs b/src-tauri/src/data/prfitem.rs index 1331cf7..429b7a5 100644 --- a/src-tauri/src/data/prfitem.rs +++ b/src-tauri/src/data/prfitem.rs @@ -282,8 +282,11 @@ impl PrfItem { let data = resp.text_with_charset("utf-8").await?; // check the data whether the valid yaml format - if !serde_yaml::from_str::(&data).is_ok() { - bail!("the remote profile data is invalid yaml"); + let yaml = serde_yaml::from_str::(&data) // + .context("the remote profile data is invalid yaml")?; + + if !yaml.contains_key("proxies") || !yaml.contains_key("proxy-providers") { + bail!("profile does not contain `proxies` or `proxy-providers`"); } Ok(PrfItem {