codec: fix incorrect handling of invalid utf-8 in LinesCodec::decode_eof (#7011)

This commit is contained in:
Zettroke
2024-12-04 10:18:14 +00:00
committed by GitHub
parent b5c227d51f
commit 129f9fc0c8
2 changed files with 14 additions and 1 deletions
+1 -1
View File
@@ -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())
}
}