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"
27
27
simplelog = " 0.5.3"
28
28
tokio = { version = " 1.2.0" , features = [" macros" , " rt-multi-thread" ] }
29
29
test-case = " 1.2.3"
30
+ proptest = " 1.0.0"
31
+
30
32
31
33
[features ]
32
34
default = [" rustls" ]
Original file line number Diff line number Diff line change @@ -289,6 +289,11 @@ impl EventParser {
289
289
290
290
if let Some ( incomplete_line) = self . incomplete_line . as_mut ( ) {
291
291
if let Some ( line) = lines. next ( ) {
292
+ assert ! (
293
+ !line. is_empty( ) ,
294
+ "split_inclusive should never yield an empty line"
295
+ ) ;
296
+
292
297
trace ! (
293
298
"extending line from previous chunk: {:?}+{:?}" ,
294
299
logify( incomplete_line) ,
@@ -370,6 +375,7 @@ impl EventParser {
370
375
#[ cfg( test) ]
371
376
mod tests {
372
377
use super :: { Error :: * , * } ;
378
+ use proptest:: proptest;
373
379
use test_case:: test_case;
374
380
375
381
fn field < ' a > ( key : & ' a str , value : & ' a str ) -> Result < Option < ( & ' a str , & ' a str ) > > {
@@ -666,4 +672,12 @@ mod tests {
666
672
std:: fs:: read ( format ! ( "test-data/{}" , name) )
667
673
. unwrap_or_else ( |_| panic ! ( "couldn't read {}" , name) )
668
674
}
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
+ }
669
683
}
You can’t perform that action at this time.
0 commit comments