From 44c7291390b88326df642778c0e075e9b34f0161 Mon Sep 17 00:00:00 2001 From: Gonne Date: Sun, 30 Mar 2025 09:35:09 +0200 Subject: [PATCH] Disallow apostrophies in mail addresses that we push to HRZ --- packages/alias-to-sieve/src/lib.rs | 18 +++++++++++++++++- .../alias-to-sieve/testdata/apostrophe.aliases | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 packages/alias-to-sieve/testdata/apostrophe.aliases diff --git a/packages/alias-to-sieve/src/lib.rs b/packages/alias-to-sieve/src/lib.rs index 35ebea2..d11d979 100644 --- a/packages/alias-to-sieve/src/lib.rs +++ b/packages/alias-to-sieve/src/lib.rs @@ -12,7 +12,7 @@ pub struct AliasFile { pub default_domain: FQDN, } -#[derive(PartialEq, Eq, Clone)] +#[derive(PartialEq, Eq, Clone, Debug)] pub struct OrdEmailAddress(EmailAddress); impl PartialOrd for OrdEmailAddress { @@ -48,6 +48,13 @@ pub fn parse_alias_to_map(alias_files: Vec) -> Result = line .split_at(line.find(char::is_whitespace).unwrap_or(0)) .1 @@ -190,6 +197,15 @@ mod tests { assert!(result.is_err()); } + #[test] + fn apostrophe_detection() { + let result = parse_alias_to_map(vec![AliasFile { + content: read_lines("testdata/apostrophe.aliases").unwrap(), + default_domain: FQDN::from_str("example.com").unwrap(), + }]); + assert!(result.is_err()); + } + #[test] fn basic_parsing() { let result = parse_alias_to_map(vec![AliasFile { diff --git a/packages/alias-to-sieve/testdata/apostrophe.aliases b/packages/alias-to-sieve/testdata/apostrophe.aliases new file mode 100644 index 0000000..37a6f91 --- /dev/null +++ b/packages/alias-to-sieve/testdata/apostrophe.aliases @@ -0,0 +1,2 @@ +# Apostrophes are not allowed by HRZ +'orga me@example.com