mirror of
https://github.com/sigoden/dufs.git
synced 2026-04-09 00:59:02 +03:00
feat: base64 index-data to avoid misencoding (#421)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use base64::{engine::general_purpose::STANDARD, Engine as _};
|
||||
use indexmap::IndexSet;
|
||||
use serde_json::Value;
|
||||
|
||||
@@ -48,7 +49,7 @@ pub fn retrieve_index_paths(content: &str) -> IndexSet<String> {
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn retrieve_edit_file(content: &str) -> Option<bool> {
|
||||
let value = retrieve_json(content)?;
|
||||
let value = retrieve_json(content).unwrap();
|
||||
let value = value.get("editable").unwrap();
|
||||
Some(value.as_bool().unwrap())
|
||||
}
|
||||
@@ -73,7 +74,9 @@ pub fn retrieve_json(content: &str) -> Option<Value> {
|
||||
let end_index = line[start_content_index..].find(end_tag)?;
|
||||
let end_content_index = start_content_index + end_index;
|
||||
|
||||
let value = line[start_content_index..end_content_index].parse().ok()?;
|
||||
let value = &line[start_content_index..end_content_index];
|
||||
let value = STANDARD.decode(value).ok()?;
|
||||
let value = serde_json::from_slice(&value).ok()?;
|
||||
|
||||
Some(value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user