mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-09-10 18:55:57 +03:00
Fix failing large note imports
When importing to Vaultwarden (or Bitwarden) notes larger then 10_000 encrypted characters are invalid. This because it for one isn't compatible with Bitwarden. And some clients tend to break on very large notes. We already added a check for this limit when adding a single cipher, but this caused issues during import, and could cause a partial imported vault. Bitwarden does some validations before actually running it through the import process and generates a special error message which helps the user indicate which items are invalid during the import. This PR adds that validation check and returns the same kind of error. Fixes #3048
This commit is contained in:
@@ -205,7 +205,7 @@ pub struct CipherData {
|
||||
*/
|
||||
pub Type: i32,
|
||||
pub Name: String,
|
||||
Notes: Option<String>,
|
||||
pub Notes: Option<String>,
|
||||
Fields: Option<Value>,
|
||||
|
||||
// Only one of these should exist, depending on type
|
||||
@@ -542,6 +542,12 @@ async fn post_ciphers_import(
|
||||
|
||||
let data: ImportData = data.into_inner().data;
|
||||
|
||||
// Validate the import before continuing
|
||||
// Bitwarden does not process the import if there is one item invalid.
|
||||
// Since we check for the size of the encrypted note length, we need to do that here to pre-validate it.
|
||||
// TODO: See if we can optimize the whole cipher adding/importing and prevent duplicate code and checks.
|
||||
Cipher::validate_notes(&data.Ciphers)?;
|
||||
|
||||
// Read and create the folders
|
||||
let mut folders: Vec<_> = Vec::new();
|
||||
for folder in data.Folders.into_iter() {
|
||||
|
Reference in New Issue
Block a user