geforkt von mirrored/vaultwarden
Fixed cipher API response to always uppercase first letter of JSON object keys
Dieser Commit ist enthalten in:
Ursprung
3b2b4d8382
Commit
b1749da9be
1 geänderte Dateien mit 16 neuen und 12 gelöschten Zeilen
|
@ -176,26 +176,30 @@ fn update_cipher_from_data(cipher: &mut Cipher, data: CipherData, headers: &Head
|
||||||
};
|
};
|
||||||
|
|
||||||
// Copy the type data and change the names to the correct case
|
// Copy the type data and change the names to the correct case
|
||||||
if !copy_values(&type_data, &mut values) {
|
copy_values(&type_data, &mut values);
|
||||||
err!("Data invalid")
|
|
||||||
}
|
|
||||||
|
|
||||||
cipher.data = values.to_string();
|
cipher.data = values.to_string();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn copy_values(from: &Value, to: &mut Value) -> bool {
|
fn copy_values(from: &Value, to: &mut Value) {
|
||||||
let map = match from.as_object() {
|
if let Some(map) = from.as_object() {
|
||||||
Some(map) => map,
|
for (key, val) in map {
|
||||||
None => return false
|
copy_values(val, &mut to[util::upcase_first(key)]);
|
||||||
};
|
}
|
||||||
|
|
||||||
for (key, val) in map {
|
} else if let Some(array) = from.as_array() {
|
||||||
to[util::upcase_first(key)] = val.clone();
|
// Initialize array with null values
|
||||||
|
*to = json!(vec![Value::Null; array.len()]);
|
||||||
|
|
||||||
|
for (index, val) in array.iter().enumerate() {
|
||||||
|
copy_values(val, &mut to[index]);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
*to = from.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
use super::folders::FolderData;
|
use super::folders::FolderData;
|
||||||
|
|
Laden …
In neuem Issue referenzieren