File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ maplit = "1.0.1"
2727simplelog = " 0.5.3"
2828tokio = { version = " 1.2.0" , features = [" macros" , " rt-multi-thread" ] }
2929test-case = " 1.2.3"
30+ proptest = " 1.0.0"
31+
3032
3133[features ]
3234default = [" rustls" ]
Original file line number Diff line number Diff line change @@ -289,6 +289,11 @@ impl EventParser {
289289
290290 if let Some ( incomplete_line) = self . incomplete_line . as_mut ( ) {
291291 if let Some ( line) = lines. next ( ) {
292+ assert ! (
293+ !line. is_empty( ) ,
294+ "split_inclusive should never yield an empty line"
295+ ) ;
296+
292297 trace ! (
293298 "extending line from previous chunk: {:?}+{:?}" ,
294299 logify( incomplete_line) ,
@@ -370,6 +375,7 @@ impl EventParser {
370375#[ cfg( test) ]
371376mod tests {
372377 use super :: { Error :: * , * } ;
378+ use proptest:: proptest;
373379 use test_case:: test_case;
374380
375381 fn field < ' a > ( key : & ' a str , value : & ' a str ) -> Result < Option < ( & ' a str , & ' a str ) > > {
@@ -666,4 +672,12 @@ mod tests {
666672 std:: fs:: read ( format ! ( "test-data/{}" , name) )
667673 . unwrap_or_else ( |_| panic ! ( "couldn't read {}" , name) )
668674 }
675+
676+ proptest ! {
677+ #[ test]
678+ fn test_decode_and_buffer_lines_does_not_crash( s in "(\r \n |\r |\n )*event: [^\n \r :]*(\r \n |\r |\n )" ) {
679+ let mut parser = EventParser :: new( ) ;
680+ parser. decode_and_buffer_lines( Bytes :: from( s) ) ;
681+ }
682+ }
669683}
You can’t perform that action at this time.
0 commit comments