mirror of
https://github.com/chatmail/relay.git
synced 2026-08-23 16:53:13 +00:00
feat!: remove passthrough options that allowed unencrypted mail to pass
see https://github.com/chatmail/relay/pull/970/ for the related removal of chatmail.ini options
This commit is contained in:
@@ -131,19 +131,6 @@ pub fn check_encrypted(mail: &mailparse::ParsedMail, outgoing: bool) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
/// Check if recipient matches a passthrough pattern
|
||||
pub fn recipient_matches_passthrough(recipient: &str, passthrough_recipients: &[String]) -> bool {
|
||||
for addr in passthrough_recipients {
|
||||
if recipient == addr {
|
||||
return true;
|
||||
}
|
||||
if addr.starts_with('@') && recipient.ends_with(addr) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -151,11 +138,6 @@ mod tests {
|
||||
use rstest::*;
|
||||
use testresult::TestResult;
|
||||
|
||||
#[fixture]
|
||||
fn passthrough_recipients() -> Vec<String> {
|
||||
vec!["pass@example.org".to_string(), "@example.com".to_string()]
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
#[case::asm("test_data/asm.eml", false)]
|
||||
#[case::encrypted("test_data/encrypted.eml", false)]
|
||||
@@ -189,18 +171,4 @@ mod tests {
|
||||
assert_eq!(check_encrypted(&parsed, false), expected);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
#[case("pass@example.org", true)]
|
||||
#[case("other@example.org", false)]
|
||||
#[case("anything@example.com", true)]
|
||||
#[case("anything@sub.example.com", false)]
|
||||
fn test_recipient_matches_passthrough(
|
||||
#[case] recipient: &str,
|
||||
#[case] expected: bool,
|
||||
passthrough_recipients: Vec<String>,
|
||||
) {
|
||||
let result = recipient_matches_passthrough(recipient, &passthrough_recipients);
|
||||
assert_eq!(result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user