mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-20 00:00:08 +02:00
codec: fix incorrect handling of invalid utf-8 in LinesCodec::decode_eof (#7011)
This commit is contained in:
@@ -169,6 +169,7 @@ impl Decoder for LinesCodec {
|
||||
Ok(match self.decode(buf)? {
|
||||
Some(frame) => Some(frame),
|
||||
None => {
|
||||
self.next_index = 0;
|
||||
// No terminating newline - return remaining data, if any
|
||||
if buf.is_empty() || buf == &b"\r"[..] {
|
||||
None
|
||||
@@ -176,7 +177,6 @@ impl Decoder for LinesCodec {
|
||||
let line = buf.split_to(buf.len());
|
||||
let line = without_carriage_return(&line);
|
||||
let line = utf8(line)?;
|
||||
self.next_index = 0;
|
||||
Some(line.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user