1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-28 01:32:57 +01:00

fix multipart boundary parsing #282

This commit is contained in:
Nikolay Kim 2018-06-05 08:52:46 -07:00
parent 960a8c425d
commit d1da227ac5

View File

@ -513,7 +513,7 @@ where
match payload.read_exact(boundary.len() + 4)? { match payload.read_exact(boundary.len() + 4)? {
Async::NotReady => Ok(Async::NotReady), Async::NotReady => Ok(Async::NotReady),
Async::Ready(None) => Err(MultipartError::Incomplete), Async::Ready(None) => Err(MultipartError::Incomplete),
Async::Ready(Some(chunk)) => { Async::Ready(Some(mut chunk)) => {
if &chunk[..2] == b"\r\n" if &chunk[..2] == b"\r\n"
&& &chunk[2..4] == b"--" && &chunk[2..4] == b"--"
&& &chunk[4..] == boundary.as_bytes() && &chunk[4..] == boundary.as_bytes()
@ -521,7 +521,10 @@ where
payload.unread_data(chunk); payload.unread_data(chunk);
Ok(Async::Ready(None)) Ok(Async::Ready(None))
} else { } 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)))
} }
} }
} }