Sieve Email Filtering: Ihave Extension
Extracted elements (18)
'ihave' is prohibited from use with grammar-changing extensions (such as variables or encoded-character) because those extensions alter how script text is parsed and interpreted, making reliable run-time capability detection impossible.
Once an 'ihave' test for an extension succeeds, that extension may be used anywhere in the script from that point forward (not only within the 'ihave' block), mirroring the semantics of having declared it in the require clause.
The 'error' control is bundled with the 'ihave' extension rather than defined separately so that it is unconditionally available to scripts that use 'ihave', without requiring a separate require declaration.
The 'ihave' extension was created to allow scripts to take advantage of optional Sieve features when available, while still running when those features are absent. This addresses portability across environments that provide different sets of extensions — something the existing static 'require' mechanism cannot handle.
An extension can appear in both the require control statement and an 'ihave' test; if the extension is implemented, it is usable throughout the script and the 'ihave' test for it will always return true, making the test redundant but not erroneous.
Because 'ihave' can appear inside 'anyof', 'allof', and 'not' tests, full parse-time checking of 'ihave' is very difficult to implement; the spec acknowledges this and permits deferring all checking to run time.
A run-time error MUST be generated if a script attempts to use an extension before a successful 'ihave' test for that extension has been evaluated.
If any capability in the 'ihave' capabilities list is unavailable, the test fails and none of the capabilities in that list are enabled.
If 'ihave' is enabled, the interpreter MUST short-circuit test evaluation (stop as soon as a result is determined) and MUST evaluate tests left to right.
Implementations MUST NOT allow 'ihave' to be used with extensions that change the underlying Sieve grammar or that change how script content is interpreted (e.g., encoded-character, variables). If such usage is attempted, the 'ihave' test MUST fail and the extension MUST NOT be enabled.
The error control's message argument SHOULD be included in any generated report regarding the script error.
The strings in the capabilities list passed to 'ihave' must be constant strings in the context of Sieve variables (RFC 5229); it is an error to pass a non-constant string as an argument to 'ihave'.
When 'ihave' is specified in the require clause, scripts MUST either defer extension-use checking to run time or take 'ihave' tests into account at parse time; normal parse-time-only checking is no longer permitted.
The 'error' control command causes script execution to terminate with a run-time error. Its sole argument is a UTF-8 string message describing the error condition, which SHOULD be included in any generated error report.
The 'ihave' test accepts a list of capability names as a string-list argument and succeeds if and only if all of those capabilities are present and available to the script. Unlike most Sieve tests, it accepts no match or comparator arguments; the match type is always ':is' and the comparator is always 'i;octet'.
RFC 5463 registers the 'ihave' capability name in the IANA Sieve Extensions registry. The capability enables run-time testing for optional extension availability and the 'error' control command.
A Sieve script that fails to run due to a missing extension may fail to block dangerous email. The 'ihave' extension improves script portability and generality, which may improve the overall security provided by Sieve filtering.
'ihave' is essentially a more flexible variant of the existing require mechanism and does not add any new capabilities to a Sieve implementation that could introduce additional security issues beyond those already present in the base specification and employed extensions.