From d1da227ac51d049687bf7f252e1096212c415607 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Tue, 5 Jun 2018 08:52:46 -0700 Subject: [PATCH] fix multipart boundary parsing #282 --- src/multipart.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/multipart.rs b/src/multipart.rs index 37244d801..f310327f4 100644 --- a/src/multipart.rs +++ b/src/multipart.rs @@ -513,7 +513,7 @@ where match payload.read_exact(boundary.len() + 4)? { Async::NotReady => Ok(Async::NotReady), Async::Ready(None) => Err(MultipartError::Incomplete), - Async::Ready(Some(chunk)) => { + Async::Ready(Some(mut chunk)) => { if &chunk[..2] == b"\r\n" && &chunk[2..4] == b"--" && &chunk[4..] == boundary.as_bytes() @@ -521,7 +521,10 @@ where payload.unread_data(chunk); Ok(Async::Ready(None)) } else { - Ok(Async::Ready(Some(chunk))) + // \r might be part of data stream + let ch = chunk.split_to(1); + payload.unread_data(chunk); + Ok(Async::Ready(Some(ch))) } } }