From 9694af82f4dcf99243f926a79d1d8512789aceaf Mon Sep 17 00:00:00 2001 From: GyDi Date: Fri, 6 May 2022 01:26:24 +0800 Subject: [PATCH] feat: check the remote profile --- src-tauri/src/core/prfitem.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src-tauri/src/core/prfitem.rs b/src-tauri/src/core/prfitem.rs index f3cb555..512700b 100644 --- a/src-tauri/src/core/prfitem.rs +++ b/src-tauri/src/core/prfitem.rs @@ -1,6 +1,7 @@ use crate::utils::{dirs, help, tmpl}; use anyhow::{bail, Context, Result}; use serde::{Deserialize, Serialize}; +use serde_yaml::Mapping; use std::fs; #[derive(Debug, Clone, Deserialize, Serialize)] @@ -228,6 +229,11 @@ impl PrfItem { let name = name.unwrap_or(uid.clone()); 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 not valid yaml"); + } + Ok(PrfItem { uid: Some(uid), itype: Some("remote".into()),