This commit is contained in:
mdecimus
2023-10-07 08:53:35 +02:00
parent 4ae0ede9ee
commit a0812095ef
21 changed files with 181 additions and 64 deletions

View File

@@ -5,7 +5,7 @@ authors = ["Stalwart Labs Ltd. <hello@stalw.art>"]
license = "AGPL-3.0-only"
repository = "https://github.com/stalwartlabs/cli"
homepage = "https://github.com/stalwartlabs/cli"
version = "0.3.8"
version = "0.3.9"
edition = "2021"
readme = "README.md"
resolver = "2"

View File

@@ -186,7 +186,9 @@ impl Lookup {
match self {
Lookup::Directory { directory, query } => match directory.query(query, &[item]).await {
Ok(mut result) => match result.len() {
1 => result.pop().map(Variable::from).unwrap(),
1 if !matches!(result.first(), Some(QueryColumn::Null)) => {
result.pop().map(Variable::from).unwrap()
}
0 => Variable::default(),
_ => Variable::Array(result.into_iter().map(Variable::from).collect()),
}

View File

@@ -1,6 +1,6 @@
[package]
name = "imap"
version = "0.3.8"
version = "0.3.9"
edition = "2021"
resolver = "2"

View File

@@ -5,7 +5,7 @@ authors = ["Stalwart Labs Ltd. <hello@stalw.art>"]
license = "AGPL-3.0-only"
repository = "https://github.com/stalwartlabs/mail-server"
homepage = "https://github.com/stalwartlabs/mail-server"
version = "0.3.8"
version = "0.3.9"
edition = "2021"
readme = "README.md"
resolver = "2"

View File

@@ -1,6 +1,6 @@
[package]
name = "jmap"
version = "0.3.8"
version = "0.3.9"
edition = "2021"
resolver = "2"
@@ -44,9 +44,9 @@ aes = "0.8.3"
cbc = { version = "0.1.2", features = ["alloc"] }
sequoia-openpgp = { version = "1.16", default-features = false, features = ["crypto-rust", "allow-experimental-crypto", "allow-variable-time-crypto"] }
rand = "0.8.5"
rasn = "0.9.5"
rasn-cms = "0.9.5"
rasn-pkix = "0.9.5"
rasn = "0.10"
rasn-cms = "0.10"
rasn-pkix = "0.10"
rsa = "0.9.2"
async-trait = "0.1.68"

View File

@@ -7,7 +7,7 @@ homepage = "https://stalw.art"
keywords = ["imap", "jmap", "smtp", "email", "mail", "server"]
categories = ["email"]
license = "AGPL-3.0-only"
version = "0.3.8"
version = "0.3.9"
edition = "2021"
resolver = "2"

View File

@@ -7,7 +7,7 @@ homepage = "https://stalw.art/smtp"
keywords = ["smtp", "email", "mail", "server"]
categories = ["email"]
license = "AGPL-3.0-only"
version = "0.3.8"
version = "0.3.9"
edition = "2021"
resolver = "2"

View File

@@ -22,6 +22,7 @@
*/
use crate::config::scripts::SieveContext;
use directory::QueryColumn;
use sieve::{runtime::Variable, FunctionMap};
use super::PluginContext;
@@ -75,7 +76,9 @@ pub fn exec(ctx: PluginContext<'_>) -> Variable<'static> {
&parameters.iter().map(String::as_str).collect::<Vec<_>>(),
)) {
match query_columns.len() {
1 => query_columns.pop().map(Variable::from).unwrap(),
1 if !matches!(query_columns.first(), Some(QueryColumn::Null)) => {
query_columns.pop().map(Variable::from).unwrap()
}
0 => Variable::default(),
_ => Variable::Array(query_columns.into_iter().map(Variable::from).collect()),
}

View File

@@ -1,6 +1,6 @@
[package]
name = "utils"
version = "0.3.8"
version = "0.3.9"
edition = "2021"
resolver = "2"
@@ -29,3 +29,6 @@ tracing-journald = "0.3"
[features]
test_mode = []
[dev-dependencies]
tokio = { version = "1.23", features = ["full"] }

View File

@@ -378,6 +378,35 @@ impl<'x> TomlParser<'x> {
}
}
}
'!' => {
let mut value = String::with_capacity(4);
while let Some(ch) = self.iter.peek() {
if ch.is_alphanumeric() || ['_', '-'].contains(ch) {
value.push(self.next_char(true, false)?);
} else {
break;
}
}
let value = match std::env::var(value.as_str()) {
Ok(value) => value,
Err(_) => {
tracing::warn!("Failed to get environment variable {value:?}");
String::new()
}
};
match self.keys.entry(key) {
Entry::Vacant(e) => {
e.insert(value);
}
Entry::Occupied(e) => {
return Err(format!(
"Duplicate key {:?} at line {}.",
e.key(),
self.line
));
}
}
}
ch => {
return if stop_chars.contains(&ch) {
Ok(ch)
@@ -421,11 +450,17 @@ mod tests {
#[test]
fn toml_parse() {
let mut file = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
file.push("resources");
file.push("tests");
file.push("config");
file.push("toml-parser.toml");
let file = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.parent()
.unwrap()
.parent()
.unwrap()
.to_path_buf()
.join("tests")
.join("resources")
.join("smtp")
.join("config")
.join("toml-parser.toml");
let config = Config::parse(&fs::read_to_string(file).unwrap()).unwrap();
assert_eq!(
@@ -539,6 +574,8 @@ mod tests {
"strings.my \"string\" test.str3".to_string(),
"Name\tTabs\nNew Line.".to_string()
),
("env.var1".to_string(), "utils".to_string()),
("env.var2".to_string(), "utils".to_string()),
])
);
}