Tolerate \r and \n inside retured data-lines

This commit is contained in:
Rodolphe Bréard 2020-12-21 15:31:52 +01:00
parent b15c236da2
commit be1b86905c

View file

@ -2,7 +2,15 @@ use crate::FilterEntry;
use std::io::{self, Write}; use std::io::{self, Write};
pub fn return_data_line(entry: &FilterEntry, data_line: &[u8]) { pub fn return_data_line(entry: &FilterEntry, data_line: &[u8]) {
let mut data_line = data_line.to_vec();
data_line.retain(|&c| c != 0x0d && c != 0x0a);
print!("filter-dataline|{}|{}|", entry.session_id, entry.token); print!("filter-dataline|{}|{}|", entry.session_id, entry.token);
io::stdout().write_all(data_line).unwrap(); io::stdout().write_all(&data_line).unwrap();
println!(); println!();
log::trace!(
"Sent filter-dataline (session:id: {}, token: {}){}",
entry.session_id,
entry.token,
crate::error::get_pretty_hex(&data_line)
);
} }