Skip to content
Snippets Groups Projects
Unverified Commit bba03d14 authored by GyDi's avatar GyDi Committed by GitHub
Browse files

fix: compatible with UTF8 BOM, close #283

parent 23b728a7
No related branches found
No related tags found
No related merge requests found
...@@ -282,8 +282,11 @@ impl PrfItem { ...@@ -282,8 +282,11 @@ impl PrfItem {
let name = name.unwrap_or(filename.unwrap_or("Remote File".into())); let name = name.unwrap_or(filename.unwrap_or("Remote File".into()));
let data = resp.text_with_charset("utf-8").await?; let data = resp.text_with_charset("utf-8").await?;
// process the charset "UTF-8 with BOM"
let data = data.trim_start_matches('\u{feff}');
// check the data whether the valid yaml format // check the data whether the valid yaml format
let yaml = serde_yaml::from_str::<Mapping>(&data) // let yaml = serde_yaml::from_str::<Mapping>(data)
.context("the remote profile data is invalid yaml")?; .context("the remote profile data is invalid yaml")?;
if !yaml.contains_key("proxies") && !yaml.contains_key("proxy-providers") { if !yaml.contains_key("proxies") && !yaml.contains_key("proxy-providers") {
...@@ -301,7 +304,7 @@ impl PrfItem { ...@@ -301,7 +304,7 @@ impl PrfItem {
extra, extra,
option, option,
updated: Some(chrono::Local::now().timestamp() as usize), updated: Some(chrono::Local::now().timestamp() as usize),
file_data: Some(data), file_data: Some(data.into()),
}) })
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment