Sieve: accept the pre-rename vnd.stalwart.* extension names #212

Merged
jcoffey-dev merged 1 commits from fix/sieve-legacy-extension-names into main 2026-10-27 06:56:40 +00:00
3 changed files with 41 additions and 1 deletions

No files matched your search

+6
View File
@@ -23,6 +23,12 @@ crates/migration/src/lib.rs "STALWART_SPAM_CLASSIFIER_MODEL.lz4"
crates/migration/src/lib.rs "STALWART_SPAM_TRAIN_DATA.lz4"
crates/types/src/branding.rs "STALWART"
# Pre-rename Sieve extension names, accepted as aliases so scripts written
# for upstream still compile when edited. Never advertised; the test proves it.
vendor/sieve-rs/src/compiler/grammar/mod.rs "vnd.stalwart.while"
vendor/sieve-rs/src/compiler/grammar/mod.rs "vnd.stalwart.expressions"
vendor/sieve-rs/src/compiler/grammar/mod.rs "require [\\\"vnd.stalwart.expressions\\\", \\\"variables\\\"];\\nlet \\\"n\\\" \\\"1 + 2\\\";\\n"
# Upstream's old default rules source, read only to treat it as unset: the
# server uses the rules bundled with it (resources/spam-filter/).
crates/common/src/manager/spam_rules.rs "https://github.com/stalwartlabs/spam-filter/releases/latest/download/spam-filter-rules.json.gz"
+5 -1
View File
@@ -11,7 +11,11 @@ Every changed file carries the AGPL 5(a) notice in its header.
- `src/compiler/grammar/mod.rs`: the extensions scripts `require` and
ManageSieve advertises are `vnd.inbuxa.while` and
`vnd.inbuxa.expressions`.
`vnd.inbuxa.expressions`. The pre-rename `vnd.stalwart.*` spellings are
still accepted, never advertised, so a script written for upstream compiles
when it's edited. Without them, the name is treated as an unknown extension
and `let` or `eval` fails with "Undeclared capability". The
`legacy_extension_names` tests cover both.
- `src/runtime/mod.rs`: the default `environment "name"` is `inbuxa Sieve`
(the server sets its own name on both of its runtimes anyway), and the
test-only capability is `vnd.inbuxa.testsuite`.
+30
View File
@@ -732,5 +732,35 @@ fn lookup_capabilities(input: &str) -> Option<Capability> {
// Extensions
"vnd.inbuxa.while" => Capability::While,
"vnd.inbuxa.expressions" => Capability::Expressions,
// The pre-rename spellings, so scripts written for upstream still
// compile when they're edited. They're never advertised.
"vnd.stalwart.while" => Capability::While,
"vnd.stalwart.expressions" => Capability::Expressions,
)
}
#[cfg(test)]
mod legacy_extension_names {
use super::Capability;
use crate::Compiler;
#[test]
fn old_spelling_parses_new_spelling_is_shown() {
for (old, new) in [
("vnd.stalwart.while", "vnd.inbuxa.while"),
("vnd.stalwart.expressions", "vnd.inbuxa.expressions"),
] {
let parsed = Capability::parse(old);
assert_eq!(parsed.to_string(), new);
assert_eq!(parsed, Capability::parse(new));
}
}
#[test]
fn script_using_old_spelling_compiles() {
let script = b"require [\"vnd.stalwart.expressions\", \"variables\"];\nlet \"n\" \"1 + 2\";\n";
Compiler::new()
.compile(script)
.expect("a script requiring the pre-rename name compiles");
}
}