File tree Expand file tree Collapse file tree 4 files changed +8
-7
lines changed Expand file tree Collapse file tree 4 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -223,8 +223,9 @@ pub(crate) const WORSE_AVATAR_BYTES: usize = 20_000; // this also fits to Outloo
223
223
pub const BALANCED_IMAGE_SIZE : u32 = 1280 ;
224
224
pub const WORSE_IMAGE_SIZE : u32 = 640 ;
225
225
226
- // Limit displayed images ~8.3 megapixels (3840 × 2160)
227
- pub const MAX_IMAGE_PIXELS : u32 = 8294400 ;
226
+ /// Limit for received images size. Bigger images become `Viewtype::File` to avoid excessive memory
227
+ /// usage by UIs.
228
+ pub const MAX_RCVD_IMAGE_PIXELS : u32 = 50_000_000 ;
228
229
229
230
// Key for the folder configuration version (see below).
230
231
pub ( crate ) const DC_FOLDERS_CONFIGURED_KEY : & str = "folders_configured" ;
Original file line number Diff line number Diff line change @@ -1386,7 +1386,7 @@ impl MimeMessage {
1386
1386
{
1387
1387
match get_filemeta ( decoded_data) {
1388
1388
// image size is known, not too big, keep msg_type:
1389
- Ok ( ( width, height) ) if width * height <= constants:: MAX_IMAGE_PIXELS => {
1389
+ Ok ( ( width, height) ) if width * height <= constants:: MAX_RCVD_IMAGE_PIXELS => {
1390
1390
part. param . set_i64 ( Param :: Width , width. into ( ) ) ;
1391
1391
part. param . set_i64 ( Param :: Height , height. into ( ) ) ;
1392
1392
msg_type
Original file line number Diff line number Diff line change @@ -2004,7 +2004,7 @@ async fn test_huge_image_becomes_file() -> Result<()> {
2004
2004
let t = TestContext :: new_alice ( ) . await ;
2005
2005
let msg_id = receive_imf (
2006
2006
& t,
2007
- include_bytes ! ( "../../test-data/message/image_huge_36M .eml" ) ,
2007
+ include_bytes ! ( "../../test-data/message/image_huge_64M .eml" ) ,
2008
2008
false ,
2009
2009
)
2010
2010
. await ?
@@ -2017,8 +2017,8 @@ async fn test_huge_image_becomes_file() -> Result<()> {
2017
2017
assert_eq ! ( msg. get_filename( ) . unwrap( ) , "huge_image.png" ) ;
2018
2018
assert_eq ! ( msg. get_filemime( ) . unwrap( ) , "image/png" ) ;
2019
2019
// File has no width or height
2020
- assert_eq ! ( msg. param. get_int( Param :: Width ) . unwrap_or_default ( ) , 0 ) ;
2021
- assert_eq ! ( msg. param. get_int( Param :: Height ) . unwrap_or_default ( ) , 0 ) ;
2020
+ assert ! ( msg. param. get_int( Param :: Width ) . is_none ( ) ) ;
2021
+ assert ! ( msg. param. get_int( Param :: Height ) . is_none ( ) ) ;
2022
2022
Ok ( ( ) )
2023
2023
}
2024
2024
Original file line number Diff line number Diff line change @@ -24,5 +24,5 @@ Content-Transfer-Encoding: base64
24
24
Content-Disposition : attachment;
25
25
filename="huge_image.png"
26
26
27
- iVBORw0KGgoAAAANSUhEUgAAF3AAABdwCAIAAABsNhAUAAAAEElEQVR4nAEFAPr /AP////8AAAAFCeiupAAAAABJRU5ErkJggg==
27
+ iVBORw0KGgoAAAANSUhEUgAAH0AAAB9ACAIAAACJkzqjAAAAEElEQVR4nAEFAPr /AP////8AAAAFCeiupAAAAABJRU5ErkJggg==
28
28
--------------HUGE_IMAGE_BOUNDARY--
You can’t perform that action at this time.
0 commit comments