Skip to content

Commit

Permalink
allow CLI to upload files with truncated filenames (#5618)
Browse files Browse the repository at this point in the history
due to a bug in the CLI the filename in the form-data is not complete if
the encrypted filename happens to contain a /
  • Loading branch information
stefan0xC authored Feb 19, 2025
1 parent 3baffee commit 359a4a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/api/core/sends.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,11 @@ async fn post_send_file_v2_data(
};

match data.data.raw_name() {
Some(raw_file_name) if raw_file_name.dangerous_unsafe_unsanitized_raw() == send_data.fileName => (),
Some(raw_file_name)
if raw_file_name.dangerous_unsafe_unsanitized_raw() == send_data.fileName
// be less strict only if using CLI, cf. https://github.com/dani-garcia/vaultwarden/issues/5614
|| (headers.device.is_cli() && send_data.fileName.ends_with(raw_file_name.dangerous_unsafe_unsanitized_raw().as_str())
) => {}
Some(raw_file_name) => err!(
"Send file name does not match.",
format!(
Expand Down
4 changes: 4 additions & 0 deletions src/db/models/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ impl Device {
pub fn is_registered(&self) -> bool {
self.push_uuid.is_some()
}

pub fn is_cli(&self) -> bool {
matches!(DeviceType::from_i32(self.atype), DeviceType::WindowsCLI | DeviceType::MacOsCLI | DeviceType::LinuxCLI)
}
}

pub struct DeviceWithAuthRequest {
Expand Down

0 comments on commit 359a4a0

Please sign in to comment.