Skip to content

Commit

Permalink
Return empty header addresses in lists
Browse files Browse the repository at this point in the history
  • Loading branch information
mdecimus committed Sep 24, 2023
1 parent d637bac commit 85da5c0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/runtime/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,11 @@ impl HeaderVariable {
.map(Variable::from),
Ordering::Equal => {
for item in list {
if let Some(part) = part.eval_strict(item) {
result.push(Variable::from(part));
}
result.push(
part.eval_strict(item)
.map(Variable::from)
.unwrap_or_default(),
);
}
return;
}
Expand All @@ -351,9 +353,11 @@ impl HeaderVariable {
.map(|s| Variable::String(s.to_string())),
Ordering::Equal => {
for item in list {
if let Some(part) = part.eval_strict(item) {
result.push(Variable::String(part.to_string()));
}
result.push(
part.eval_strict(item)
.map(|s| Variable::String(s.to_string()))
.unwrap_or_default(),
);
}
return;
}
Expand Down
7 changes: 7 additions & 0 deletions tests/stalwart/extensions.svtest
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ test "Variable scopes" {
test_set "message" text:
From: Giovanni
To: [email protected]
Cc: User <[email protected]>, invalid, User2 <[email protected]>
Bcc: Test <[email protected]>, Test 1 <[email protected]>
Bcc: Test 2 <[email protected]>, Test 3 <[email protected]>
X-Confirm-Reading-To: <[email protected]>
Subject: Pranzo d'acqua fa volti sghembi

Expand All @@ -139,4 +142,8 @@ test "Header addresses" {
if not eval "header.X-Confirm-Reading-To.addr == '[email protected]'" {
test_fail "header.X-Confirm-Reading-To.addr != '[email protected]'";
}

if not eval "header.from:to:cc:bcc:X-Confirm-Reading-To[*].addr[*] == ['', '[email protected]', '[email protected]', '', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]']" {
test_fail "header.from:to:cc:bcc:X-Confirm-Reading-To[*].addr[*] = [%{header.from:to:cc:bcc:X-Confirm-Reading-To[*].addr[*]}]";
}
}

0 comments on commit 85da5c0

Please sign in to comment.