diff --git a/CHANGELOG.md b/CHANGELOG.md index d9fe32c1..3ff03501 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). -## [0.5.1] - 2024-01-xx +## [0.5.1] - 2024-01-02 ## Added - SMTP smuggling protection: Sanitization of outgoing messages that do not use `CRLF` as line endings. @@ -13,8 +13,9 @@ All notable changes to this project will be documented in this file. This projec ### Fixed - Invalid DKIM signatures for empty message bodies. - IMAP command `SEARCH BEFORE` is not properly parsed. -- IMAP response to `ENABLE` command misses enabled capabilities list. +- IMAP command `FETCH` fails to parse single arguments without parentheses. - IMAP command `ENABLE QRESYNC` should also enable `CONDSTORE` extension. +- IMAP response to `ENABLE` command does not include enabled capabilities list. - IMAP response to `FETCH ENVELOPE` should not return `NIL` when the `From` header is missing. ## [0.5.0] - 2023-12-27 diff --git a/Cargo.lock b/Cargo.lock index 7eddb06c..9901a578 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2545,7 +2545,7 @@ checksum = "029d73f573d8e8d63e6d5020011d3255b28c3ba85d6cf870a07184ed23de9284" [[package]] name = "imap" -version = "0.5.0" +version = "0.5.1" dependencies = [ "ahash 0.8.7", "dashmap", @@ -2722,7 +2722,7 @@ dependencies = [ [[package]] name = "jmap" -version = "0.5.0" +version = "0.5.1" dependencies = [ "aes", "aes-gcm", @@ -3132,7 +3132,7 @@ dependencies = [ [[package]] name = "mail-server" -version = "0.5.0" +version = "0.5.1" dependencies = [ "directory", "imap", @@ -3149,7 +3149,7 @@ dependencies = [ [[package]] name = "managesieve" -version = "0.5.0" +version = "0.5.1" dependencies = [ "ahash 0.8.7", "bincode", @@ -3416,7 +3416,7 @@ dependencies = [ [[package]] name = "nlp" -version = "0.5.0" +version = "0.5.1" dependencies = [ "ahash 0.8.7", "bincode", @@ -5357,7 +5357,7 @@ checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "smtp" -version = "0.5.0" +version = "0.5.1" dependencies = [ "ahash 0.8.7", "bincode", @@ -5479,7 +5479,7 @@ dependencies = [ [[package]] name = "stalwart-cli" -version = "0.5.0" +version = "0.5.1" dependencies = [ "clap", "console", @@ -5503,7 +5503,7 @@ dependencies = [ [[package]] name = "stalwart-install" -version = "0.5.0" +version = "0.5.1" dependencies = [ "base64 0.21.5", "clap", @@ -6385,7 +6385,7 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "utils" -version = "0.5.0" +version = "0.5.1" dependencies = [ "ahash 0.8.7", "chrono", diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index ff3d3089..12963d47 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Stalwart Labs Ltd. "] license = "AGPL-3.0-only" repository = "https://github.com/stalwartlabs/cli" homepage = "https://github.com/stalwartlabs/cli" -version = "0.5.0" +version = "0.5.1" edition = "2021" readme = "README.md" resolver = "2" diff --git a/crates/imap-proto/src/parser/fetch.rs b/crates/imap-proto/src/parser/fetch.rs index 35c65eed..2e43be16 100644 --- a/crates/imap-proto/src/parser/fetch.rs +++ b/crates/imap-proto/src/parser/fetch.rs @@ -343,6 +343,10 @@ impl Request { ) .into()); } + + if !in_parentheses { + break; + } } Token::ParenthesisOpen => { if !in_parentheses { @@ -778,6 +782,16 @@ mod tests { include_vanished: true, }, ), + ( + "9 UID FETCH 1:* UID (VANISHED CHANGEDSINCE 1)\r\n", + fetch::Arguments { + tag: "9".to_string(), + sequence_set: Sequence::range(1.into(), None), + attributes: vec![Attribute::Uid], + changed_since: 1.into(), + include_vanished: true, + }, + ), ] { assert_eq!( receiver diff --git a/crates/imap-proto/src/protocol/fetch.rs b/crates/imap-proto/src/protocol/fetch.rs index 48884784..61f2930d 100644 --- a/crates/imap-proto/src/protocol/fetch.rs +++ b/crates/imap-proto/src/protocol/fetch.rs @@ -1300,7 +1300,7 @@ mod tests { concat!( "BODYSTRUCTURE (((\"text\" \"PLAIN\" (\"CHARSET\" \"UTF-8\") ", "\"<111@domain.com>\" \"Text part\" \"7BIT\" 1152 23 \"8o3456\" ", - "(\"inline\" ()) \"en-US\" \"right here\")", + "(\"inline\" NIL) \"en-US\" \"right here\")", "(\"text\" \"HTML\" (\"CHARSET\" \"UTF-8\") ", "\"<54535@domain.com>\" \"HTML part\" \"8BIT\" 45345 994 \"53454\" ", "(\"attachment\" (\"filename\" \"myfile.txt\")) ", diff --git a/crates/imap/Cargo.toml b/crates/imap/Cargo.toml index 413a9a6b..f13cdb9e 100644 --- a/crates/imap/Cargo.toml +++ b/crates/imap/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "imap" -version = "0.5.0" +version = "0.5.1" edition = "2021" resolver = "2" diff --git a/crates/install/Cargo.toml b/crates/install/Cargo.toml index 22f79a8f..d3eec77c 100644 --- a/crates/install/Cargo.toml +++ b/crates/install/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Stalwart Labs Ltd. "] license = "AGPL-3.0-only" repository = "https://github.com/stalwartlabs/mail-server" homepage = "https://github.com/stalwartlabs/mail-server" -version = "0.5.0" +version = "0.5.1" edition = "2021" readme = "README.md" resolver = "2" diff --git a/crates/jmap/Cargo.toml b/crates/jmap/Cargo.toml index 1ea025a6..b6b71f94 100644 --- a/crates/jmap/Cargo.toml +++ b/crates/jmap/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "jmap" -version = "0.5.0" +version = "0.5.1" edition = "2021" resolver = "2" diff --git a/crates/main/Cargo.toml b/crates/main/Cargo.toml index 4006565a..90976ec4 100644 --- a/crates/main/Cargo.toml +++ b/crates/main/Cargo.toml @@ -7,7 +7,7 @@ homepage = "https://stalw.art" keywords = ["imap", "jmap", "smtp", "email", "mail", "server"] categories = ["email"] license = "AGPL-3.0-only" -version = "0.5.0" +version = "0.5.1" edition = "2021" resolver = "2" diff --git a/crates/managesieve/Cargo.toml b/crates/managesieve/Cargo.toml index 74cb0465..ba51fff4 100644 --- a/crates/managesieve/Cargo.toml +++ b/crates/managesieve/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "managesieve" -version = "0.5.0" +version = "0.5.1" edition = "2021" resolver = "2" diff --git a/crates/nlp/Cargo.toml b/crates/nlp/Cargo.toml index 3d70992f..8f72759f 100644 --- a/crates/nlp/Cargo.toml +++ b/crates/nlp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nlp" -version = "0.5.0" +version = "0.5.1" edition = "2021" resolver = "2" diff --git a/crates/smtp/Cargo.toml b/crates/smtp/Cargo.toml index be0331c4..f807291d 100644 --- a/crates/smtp/Cargo.toml +++ b/crates/smtp/Cargo.toml @@ -7,7 +7,7 @@ homepage = "https://stalw.art/smtp" keywords = ["smtp", "email", "mail", "server"] categories = ["email"] license = "AGPL-3.0-only" -version = "0.5.0" +version = "0.5.1" edition = "2021" resolver = "2" diff --git a/crates/utils/Cargo.toml b/crates/utils/Cargo.toml index 881ff990..f30dad05 100644 --- a/crates/utils/Cargo.toml +++ b/crates/utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "utils" -version = "0.5.0" +version = "0.5.1" edition = "2021" resolver = "2" diff --git a/tests/resources/scripts/create_test_users.sh b/tests/resources/scripts/create_test_users.sh index 5e0f295c..84979ce9 100644 --- a/tests/resources/scripts/create_test_users.sh +++ b/tests/resources/scripts/create_test_users.sh @@ -13,4 +13,4 @@ cargo run -p stalwart-cli -- -u https://127.0.0.1:8080 -c admin:secret account c #cargo run -p stalwart-cli -- -u https://127.0.0.1:8080 -c admin:secret list add-members everyone jane john bill #cargo run -p stalwart-cli -- -u https://127.0.0.1:8080 -c admin:secret account list #cargo run -p stalwart-cli -- -u https://127.0.0.1:8080 -c admin:secret import messages --format mbox john _ignore/dovecot-crlf - +#cargo run -p stalwart-cli -- -u https://127.0.0.1:8080 -c admin:secret import messages --format maildir john /var/mail/john diff --git a/tests/resources/scripts/imap_import_single.py b/tests/resources/scripts/imap_import_single.py new file mode 100644 index 00000000..e45c5982 --- /dev/null +++ b/tests/resources/scripts/imap_import_single.py @@ -0,0 +1,27 @@ +import imaplib +import socket +import time +from email.message import Message +from email.utils import formatdate +from datetime import datetime, timedelta + +conn = imaplib.IMAP4('localhost') +conn.login('john', '12345') +conn.socket().setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) +current_date = datetime.now() +timestamp = current_date.timestamp() + +msg = Message() +msg['From'] = 'somebody@some.where' +msg['To'] = 'john@example.org' +msg['Message-Id'] = f'unique.message.id.{current_date}@nowhere' +msg['Date'] = formatdate(time.mktime(current_date.timetuple()), localtime=False, usegmt=True) +msg['Subject'] = f"This is message #{timestamp}" +msg.set_payload('...nothing...') + +response_code, response_details = conn.append('INBOX', '', imaplib.Time2Internaldate(time.mktime(current_date.timetuple())), str(msg).encode('utf-8')) +if response_code != 'OK': + print(f'Error while appending message: {response_code} {response_details}') + +print("Message appended.") +conn.logout()