vw_small

Hardened fork of Vaultwarden (https://github.com/dani-garcia/vaultwarden) with fewer features.
git clone https://git.philomathiclife.com/repos/vw_small
Log | Files | Refs | README

commit b1749da9be9233c9e772673c978f17a4059189a3
parent 3b2b4d838261bf108b3f9234b1eb1eb4d2181709
Author: Daniel GarcĂ­a <dani-garcia@users.noreply.github.com>
Date:   Wed, 21 Mar 2018 01:07:48 +0100

Fixed cipher API response to always uppercase first letter of JSON object keys

Diffstat:
Msrc/api/core/ciphers.rs | 28++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/src/api/core/ciphers.rs b/src/api/core/ciphers.rs @@ -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 - if !copy_values(&type_data, &mut values) { - err!("Data invalid") - } + copy_values(&type_data, &mut values); cipher.data = values.to_string(); Ok(()) } -fn copy_values(from: &Value, to: &mut Value) -> bool { - let map = match from.as_object() { - Some(map) => map, - None => return false - }; +fn copy_values(from: &Value, to: &mut Value) { + if let Some(map) = from.as_object() { + for (key, val) in map { + copy_values(val, &mut to[util::upcase_first(key)]); + } - for (key, val) in map { - to[util::upcase_first(key)] = val.clone(); - } + } else if let Some(array) = from.as_array() { + // Initialize array with null values + *to = json!(vec![Value::Null; array.len()]); - true + for (index, val) in array.iter().enumerate() { + copy_values(val, &mut to[index]); + } + + } else { + *to = from.clone(); + } } use super::folders::FolderData;