mirror of
https://github.com/actix/actix-web.git
synced 2024-12-24 09:00:34 +00:00
fix multipart boundary parsing #282
This commit is contained in:
parent
89fc6b6ac9
commit
6a40a0a466
1 changed files with 5 additions and 2 deletions
|
@ -511,7 +511,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()
|
||||||
|
@ -519,7 +519,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)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue