File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -2470,4 +2470,24 @@ mod tests {
24702470 assert_eq ! ( metadata[ 1 ] . value, None ) ;
24712471 }
24722472 }
2473+
2474+ #[ cfg_attr( feature = "runtime-tokio" , tokio:: test) ]
2475+ #[ cfg_attr( feature = "runtime-async-std" , async_std:: test) ]
2476+ async fn test_parsing_error ( ) {
2477+ // Simulate someone connecting to SMTP server with IMAP client.
2478+ let response = b"220 mail.example.org ESMTP Postcow\r \n " . to_vec ( ) ;
2479+ let command = "A0001 NOOP\r \n " ;
2480+ let mock_stream = MockStream :: new ( response) ;
2481+ let mut session = mock_session ! ( mock_stream) ;
2482+ assert ! ( session
2483+ . noop( )
2484+ . await
2485+ . unwrap_err( )
2486+ . to_string( )
2487+ . contains( "220 mail.example.org ESMTP Postcow" ) ) ;
2488+ assert ! (
2489+ session. stream. inner. written_buf == command. as_bytes( ) . to_vec( ) ,
2490+ "Invalid NOOP command"
2491+ ) ;
2492+ }
24732493}
Original file line number Diff line number Diff line change @@ -105,7 +105,11 @@ impl<R: Read + Write + Unpin> ImapStream<R> {
105105 self . decode_needs = 0 ;
106106 Err ( Some ( io:: Error :: new (
107107 io:: ErrorKind :: Other ,
108- format ! ( "{:?} during parsing of {:?}" , other, buf) ,
108+ format ! (
109+ "{:?} during parsing of {:?}" ,
110+ other,
111+ String :: from_utf8_lossy( buf)
112+ ) ,
109113 ) ) )
110114 }
111115 }
You can’t perform that action at this time.
0 commit comments