mirror of
https://github.com/stalwartlabs/mail-server.git
synced 2025-10-08 19:45:49 +08:00
Remove CRLF from Milter headers
This commit is contained in:
parent
fe2e4079d3
commit
a0ceaeba1c
3 changed files with 12 additions and 7 deletions
|
@ -227,14 +227,14 @@ impl<T: AsyncRead + AsyncWrite + Unpin> MilterClient<T> {
|
|||
pub async fn headers<I, H, V>(&mut self, headers: I) -> super::Result<Action>
|
||||
where
|
||||
I: Iterator<Item = (H, V)>,
|
||||
H: AsRef<[u8]>,
|
||||
V: AsRef<[u8]>,
|
||||
H: AsRef<str>,
|
||||
V: AsRef<str>,
|
||||
{
|
||||
if !self.has_option(SMFIP_NOHDRS) {
|
||||
for (name, value) in headers {
|
||||
self.write(Command::Header {
|
||||
name: name.as_ref(),
|
||||
value: value.as_ref(),
|
||||
name: name.as_ref().trim().as_bytes(),
|
||||
value: value.as_ref().trim().as_bytes(),
|
||||
})
|
||||
.await?;
|
||||
if !self.has_option(SMFIP_NR_HDR) {
|
||||
|
|
|
@ -219,7 +219,12 @@ impl<T: AsyncWrite + AsyncRead + IsTls + Unpin> Session<T> {
|
|||
|
||||
// Headers
|
||||
client
|
||||
.headers(message.raw_parsed_headers().iter().cloned())
|
||||
.headers(message.raw_parsed_headers().iter().map(|(k, v)| {
|
||||
(
|
||||
std::str::from_utf8(k).unwrap_or_default(),
|
||||
std::str::from_utf8(v).unwrap_or_default(),
|
||||
)
|
||||
}))
|
||||
.await?
|
||||
.assert_continue()?;
|
||||
|
||||
|
|
|
@ -377,9 +377,9 @@ async fn milter_client_test() {
|
|||
let mut client = MilterClient::connect(
|
||||
&Milter {
|
||||
enable: IfBlock::default(),
|
||||
addrs: vec![SocketAddr::from(([127, 0, 0, 1], 1234))],
|
||||
addrs: vec![SocketAddr::from(([127, 0, 0, 1], 11332))],
|
||||
hostname: "localhost".to_string(),
|
||||
port: 1234,
|
||||
port: 11332,
|
||||
timeout_connect: Duration::from_secs(10),
|
||||
timeout_command: Duration::from_secs(30),
|
||||
timeout_data: Duration::from_secs(30),
|
||||
|
|
Loading…
Add table
Reference in a new issue