mirror of
https://github.com/chatmail/core.git
synced 2026-04-26 01:46:34 +03:00
Introduce a BlobObject type for blobs
This creates a specific type for blobs, with well defined conversions at the borders. It also introduces a strong type for the Param::File value since that param is often used used by the public API to set filenames using absolute paths, but then core changes the param to a blob before it gets to the database. This eliminates a few more functions with very mallable C-like arguments behaviour which combine a number of operations in one. Because blob filenames are stored so often in arbitrary strings this does add more code when receiving those, until the storage is fixed. File name sanitisation is now deletated to the sanitize-filename crate which should do a slightly better job at this.
This commit is contained in:
committed by
holger krekel
parent
f0fc50d5a9
commit
6c9e16d31a
@@ -13,6 +13,7 @@ use mmime::mailmime::types::*;
|
||||
use mmime::mailmime::*;
|
||||
use mmime::other::*;
|
||||
|
||||
use crate::blob::BlobObject;
|
||||
use crate::constants::Viewtype;
|
||||
use crate::contact::*;
|
||||
use crate::context::Context;
|
||||
@@ -771,8 +772,8 @@ impl<'a> MimeParser<'a> {
|
||||
desired_filename: &str,
|
||||
) {
|
||||
/* write decoded data to new blob file */
|
||||
let bpath = match self.context.new_blob_file(desired_filename, decoded_data) {
|
||||
Ok(path) => path,
|
||||
let blob = match BlobObject::create(self.context, desired_filename, decoded_data) {
|
||||
Ok(blob) => blob,
|
||||
Err(err) => {
|
||||
error!(
|
||||
self.context,
|
||||
@@ -786,7 +787,7 @@ impl<'a> MimeParser<'a> {
|
||||
part.typ = msg_type;
|
||||
part.mimetype = mime_type;
|
||||
part.bytes = decoded_data.len() as libc::c_int;
|
||||
part.param.set(Param::File, bpath);
|
||||
part.param.set(Param::File, blob.as_name());
|
||||
if let Some(raw_mime) = raw_mime {
|
||||
part.param.set(Param::MimeType, raw_mime);
|
||||
}
|
||||
@@ -1220,6 +1221,7 @@ mod tests {
|
||||
}
|
||||
|
||||
proptest! {
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn test_dc_mailmime_parse_crash_fuzzy(data in "[!-~\t ]{2000,}") {
|
||||
// this test doesn't exercise much of dc_mimeparser anymore
|
||||
|
||||
Reference in New Issue
Block a user