Support for IMAP multiline responses in directories

This commit is contained in:
mdecimus
2023-10-25 15:57:00 +02:00
parent 96ddc7db7d
commit e551e094fd
5 changed files with 19 additions and 11 deletions

2
Cargo.lock generated
View File

@@ -2841,7 +2841,7 @@ dependencies = [
[[package]]
name = "managesieve"
version = "0.1.0"
version = "0.4.0"
dependencies = [
"ahash 0.8.3",
"bincode",

View File

@@ -28,10 +28,11 @@ Upgrading from `v0.3.x` to `v0.4.0`
- `etc/jmap/oauth.toml`
- `etc/smtp/signature.toml`
- `etc/common/tls.toml`
4. **Configure the SPAM Filter Database:** Set up and configure the SPAM filter database. More details can be found [here](https://stalw.art/docs/spamfilter/settings/database).
5. **Review All TOML Files:** Navigate to every TOML file under the `etc/` directory and make necessary changes.
6. **Update Binary:** Download and substitute the v0.4.0 binary suitable for your platform from [here](https://github.com/stalwartlabs/mail-server/releases/tag/v0.4.0).
7. **Restart Service:** Conclude by restarting the Stalwart Mail Server service.
4. **Adjust included files:** If you are using an LDAP directory for authentication, edit `etc/config.toml` and replace the `etc/directory/sql.toml` include with `etc/directory/ldap.toml`.
5. **Configure the SPAM Filter Database:** Set up and configure the SPAM filter database. More details can be found [here](https://stalw.art/docs/spamfilter/settings/database).
6. **Review All TOML Files:** Navigate to every TOML file under the `etc/` directory and make necessary changes.
7. **Update Binary:** Download and substitute the v0.4.0 binary suitable for your platform from [here](https://github.com/stalwartlabs/mail-server/releases/tag/v0.4.0).
8. **Restart Service:** Conclude by restarting the Stalwart Mail Server service.
### Alternative Method:

View File

@@ -90,12 +90,15 @@ impl<T: AsyncRead + AsyncWrite + Unpin> ImapClient<T> {
tokio::time::timeout(self.timeout, async {
self.write(b"C0 CAPABILITY\r\n").await?;
let line = self.read_line().await?;
if !matches!(line.get(..12), Some(b"* CAPABILITY")) {
return Err(ImapError::InvalidResponse(line.into_string()));
let mut line = self.read_line().await?.into_string();
if !line.starts_with("* CAPABILITY") {
return Err(ImapError::InvalidResponse(line));
}
while !line.contains("C0 ") {
line.push_str(&self.read_line().await?.into_string());
}
let mut line_iter = line.iter();
let mut line_iter = line.as_bytes().iter();
let mut parser = Rfc5321Parser::new(&mut line_iter);
let mut mechanisms = 0;

View File

@@ -1,6 +1,6 @@
[package]
name = "managesieve"
version = "0.1.0"
version = "0.4.0"
edition = "2021"
resolver = "2"

View File

@@ -198,7 +198,11 @@ async fn accept_imap(stream: TcpStream, acceptor: Arc<TlsAcceptor>, in_flight: O
panic!("Unknown command: {}", buf.trim());
};
//print!("<- {}", response);
stream.write_all(response.as_bytes()).await.unwrap();
for line in response.split_inclusive('\n') {
stream.write_all(line.as_bytes()).await.unwrap();
stream.flush().await.unwrap();
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
}
if buf.contains("bye") || buf.starts_with("LOGOUT") {
return;