@@ -5,6 +5,7 @@ use crate::ephemeral::Timer;
5
5
use crate :: headerdef:: HeaderDef ;
6
6
use crate :: imex:: { ImexMode , has_backup, imex} ;
7
7
use crate :: message:: { MessengerMessage , delete_msgs} ;
8
+ use crate :: mimeparser;
8
9
use crate :: receive_imf:: receive_imf;
9
10
use crate :: test_utils:: {
10
11
AVATAR_64x64_BYTES , AVATAR_64x64_DEDUPLICATED , TestContext , TestContextManager ,
@@ -2889,6 +2890,52 @@ async fn test_block_broadcast() -> Result<()> {
2889
2890
Ok ( ( ) )
2890
2891
}
2891
2892
2893
+ /// Tests that a List-Id header in the encrypted part
2894
+ /// overrides a List-Id header in the unencrypted part,
2895
+ /// and that the List-Id isn't visible in the unencrypted part.
2896
+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
2897
+ async fn test_broadcast_channel_protected_listid ( ) -> Result < ( ) > {
2898
+ let mut tcm = TestContextManager :: new ( ) ;
2899
+ let alice = & tcm. alice ( ) . await ;
2900
+ let bob = & tcm. bob ( ) . await ;
2901
+ let alice_bob_contact_id = alice. add_or_lookup_contact_id ( bob) . await ;
2902
+
2903
+ tcm. section ( "Create a broadcast channel with Bob, and send a message" ) ;
2904
+ let alice_chat_id = create_broadcast ( alice, "My Channel" . to_string ( ) ) . await ?;
2905
+ add_contact_to_chat ( alice, alice_chat_id, alice_bob_contact_id) . await ?;
2906
+ let mut sent = alice. send_text ( alice_chat_id, "Hi somebody" ) . await ;
2907
+
2908
+ assert ! ( !sent. payload. contains( "List-ID" ) ) ;
2909
+ // Do the counter check that the Message-Id header is present:
2910
+ assert ! ( sent. payload. contains( "Message-ID" ) ) ;
2911
+
2912
+ // Check that Delta Chat ignores an injected List-ID header:
2913
+ let new_payload = sent. payload . replace (
2914
+ "Date: " ,
2915
+ "List-ID: some wrong listid that would make things fail\n Date: " ,
2916
+ ) ;
2917
+ assert_ne ! ( & sent. payload, & new_payload) ;
2918
+ sent. payload = new_payload;
2919
+
2920
+ let alice_list_id = Chat :: load_from_db ( alice, sent. load_from_db ( ) . await . chat_id )
2921
+ . await ?
2922
+ . grpid ;
2923
+
2924
+ let parsed = mimeparser:: MimeMessage :: from_bytes ( bob, sent. payload . as_bytes ( ) , None ) . await ?;
2925
+ assert_eq ! (
2926
+ parsed. get_mailinglist_header( ) . unwrap( ) ,
2927
+ format!( "My Channel <{}>" , alice_list_id)
2928
+ ) ;
2929
+
2930
+ let rcvd = bob. recv_msg ( & sent) . await ;
2931
+ assert_eq ! (
2932
+ Chat :: load_from_db( bob, rcvd. chat_id) . await ?. grpid,
2933
+ alice_list_id
2934
+ ) ;
2935
+
2936
+ Ok ( ( ) )
2937
+ }
2938
+
2892
2939
#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
2893
2940
async fn test_create_for_contact_with_blocked ( ) -> Result < ( ) > {
2894
2941
let t = TestContext :: new ( ) . await ;
0 commit comments