Skip to content

Commit

Permalink
feat: check the remote profile
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzgydi committed May 5, 2022
1 parent 28a4386 commit 9694af8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src-tauri/src/core/prfitem.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down Expand Up @@ -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::<Mapping>(&data).is_ok() {
bail!("the remote profile data is not valid yaml");
}

Ok(PrfItem {
uid: Some(uid),
itype: Some("remote".into()),
Expand Down

0 comments on commit 9694af8

Please sign in to comment.