draft-ietf-sieve-variables-01.txt   draft-ietf-sieve-variables-02.txt 
Network Working Group K. T. Homme Network Working Group K. T. Homme
Updates: 3028 Updates: 3028
Document: draft-ietf-sieve-variables-01.txt University of Oslo Document: draft-ietf-sieve-variables-02.txt University of Oslo
Expires Aug 3, 2005 3 Feb 2005 Expires Oct 5, 2005 5 Apr 2005
Sieve Mail Filtering Language: Variables Extension Sieve Mail Filtering Language: Variables Extension
Status of this Memo Status of this Memo
This document is an Internet-Draft and is subject to all provisions This document is an Internet-Draft and is subject to all provisions
of section 3 of RFC 3667. By submitting this Internet-Draft, each of section 3 of RFC 3667. By submitting this Internet-Draft, each
author represents that any applicable patent or other IPR claims of author represents that any applicable patent or other IPR claims of
which he or she is aware have been or will be disclosed, and any of which he or she is aware have been or will be disclosed, and any of
which he or she become aware will be disclosed, in accordance with which he or she become aware will be disclosed, in accordance with
skipping to change at page 4, line 28 skipping to change at page 4, line 28
c) added Syntax line for MODIFIER. c) added Syntax line for MODIFIER.
d) added comment to an example showing that the non-greedy "*" still d) added comment to an example showing that the non-greedy "*" still
matches everything due to implicit anchors. matches everything due to implicit anchors.
e) added example of expansion of string with unbalanced braces. e) added example of expansion of string with unbalanced braces.
f) updated reference to [SPAMTEST]. f) updated reference to [SPAMTEST].
0.2.7. Changes since -01
a) moved References from appendix into the document itself.
b) added example of SET with a comparator.
c) changed "highest value" to the less ambiguous "largest value".
d) updated reference to [UTF-8].
e) allow numbered variables in namespaces.
f) change ${0} to mean the complete match.
0.3. Open Issues 0.3. Open Issues
Should we allow all-digit namespace components? e.g., array.var.2.3
to provide array variables.
This extension is in conflict with a MUST in [SIEVE] 2.4: "Tests MUST This extension is in conflict with a MUST in [SIEVE] 2.4: "Tests MUST
NOT have side effects." This document therefore can't leave draft NOT have side effects." This document therefore can't leave draft
status until a revised Sieve specification has been accepted by the status until a revised Sieve specification has been accepted by the
IESG. No significant changes to this draft are foreseen before IESG. No significant changes to this draft are foreseen before
submission as a proposed standard. submission as a proposed standard.
1. Introduction 1. Introduction
This is an extension to the Sieve language defined by [SIEVE]. It This is an extension to the Sieve language defined by [SIEVE]. It
adds support for storing and referencing named data. The mechanisms adds support for storing and referencing named data. The mechanisms
skipping to change at page 5, line 23 skipping to change at page 5, line 43
This extension changes the semantics of quoted-string, multi-line- This extension changes the semantics of quoted-string, multi-line-
literal and multi-line-dotstuff found in [SIEVE] to enable the literal and multi-line-dotstuff found in [SIEVE] to enable the
inclusion of the value of variables. inclusion of the value of variables.
When a string is evaluated, substrings matching variable-ref SHALL be When a string is evaluated, substrings matching variable-ref SHALL be
replaced by the value of variable-name. Only one pass through the replaced by the value of variable-name. Only one pass through the
string SHALL be done. Variable names are case insensitive, so "foo" string SHALL be done. Variable names are case insensitive, so "foo"
and "FOO" refer to the same variable. Unknown variables are replaced and "FOO" refer to the same variable. Unknown variables are replaced
by the empty string. by the empty string.
variable-ref = "${" variable-name "}" variable-ref = "${" *namespace variable-name "}"
variable-name = num-variable / *namespace identifier variable-name = num-variable / identifier
namespace = identifier "." namespace = identifier "."
num-variable = 1*DIGIT num-variable = 1*DIGIT
Examples: Examples:
"&%${}!" => unchanged, as the empty string is an illegal "&%${}!" => unchanged, as the empty string is an illegal
identifier identifier
"${doh!}" => unchanged, as "!" is illegal in identifiers "${doh!}" => unchanged, as "!" is illegal in identifiers
The variable company holds the value "ACME". No other variables The variable "company" holds the value "ACME". No other variables
are set. are set.
"${full}" => the empty string "${full}" => the empty string
"${company}" => "ACME" "${company}" => "ACME"
"${President, ${Company} Inc.}" "${President, ${Company} Inc.}"
=> "${President, ACME Inc.}" => "${President, ACME Inc.}"
"${BAD${Company}"=>"${BADACME" "${BAD${Company}"=>"${BADACME"
The expanded string MUST use the variable values which are current The expanded string MUST use the variable values which are current
when control reaches the statement the string is part of. when control reaches the statement the string is part of.
skipping to change at page 7, line 6 skipping to change at page 7, line 27
("?" and "*") in the match pattern. Each string holds what the ("?" and "*") in the match pattern. Each string holds what the
corresponding wildcard expands to, possibly the empty string. The corresponding wildcard expands to, possibly the empty string. The
wildcards match as little as possible (non-greedy matching). wildcards match as little as possible (non-greedy matching).
For ":regex", the list will contain the strings corresponding to the For ":regex", the list will contain the strings corresponding to the
group operators. The groups are ordered by the position of the group operators. The groups are ordered by the position of the
opening parenthesis, from left to right. Note that in regular opening parenthesis, from left to right. Note that in regular
expressions, expansions match as much as possible (greedy matching). expressions, expansions match as much as possible (greedy matching).
The first string in the list has index 1. If the index is out of The first string in the list has index 1. If the index is out of
range, the empty string will be substituted. Index 0 returns the range, the empty string will be substituted. Index 0 contains the
number of strings in the list as a decimal number. matched part of the source value.
The interpreter MUST short-circuit tests, ie. not perform more tests The interpreter MUST short-circuit tests, ie. not perform more tests
than necessary to find the result. Evaluation order MUST be left to than necessary to find the result. Evaluation order MUST be left to
right. If a test has two or more list arguments, the implementation right. If a test has two or more list arguments, the implementation
is free to choose which to iterate over first. is free to choose which to iterate over first.
Example: Example:
require [ "fileinto", "regex", "variables" ]; require [ "fileinto", "regex", "variables" ];
skipping to change at page 7, line 31 skipping to change at page 8, line 4
# This usually gives the same result as the above # This usually gives the same result as the above
if header :matches "List-ID" "*<*@*" { if header :matches "List-ID" "*<*@*" {
fileinto "lists.${2}"; stop; fileinto "lists.${2}"; stop;
} }
# Imagine the header # Imagine the header
# Subject: [acme-users] [fwd] version 1.0 is out # Subject: [acme-users] [fwd] version 1.0 is out
if header :regex "Subject" "^[(.*)] (.*)$" { if header :regex "Subject" "^[(.*)] (.*)$" {
# ${1} will hold "acme-users] [fwd" # ${1} will hold "acme-users] [fwd"
stop;
} }
if header :matches "Subject" "[*] *" { if header :matches "Subject" "[*] *" {
# ${1} will hold "acme-users", # ${1} will hold "acme-users",
# ${2} will hold "[fwd] version 1.0 is out" # ${2} will hold "[fwd] version 1.0 is out"
fileinfo "lists.${1}"; stop; fileinfo "lists.${1}"; stop;
} }
if address :matches [ "To", "Cc" ] "coyote@**.com" { if address :matches ["To", "Cc"] ["coyote@**.com",
# ${0} is always "2", and ${1} is always the empty string. "wile@**.com"] {
# ${0} is the matching address.
# ${1} is always the empty string.
fileinto "business.${2}"; stop; fileinto "business.${2}"; stop;
} else { } else {
# Control can't reach this block if any match was # Control wouldn't reach this block if any match was
# successful, so ${0} is always "0" here. # successful, so no numbered variables are set at this
# point.
} }
if anyof (true, address :domain :matches "To" "*.com") { if anyof (true, address :domain :matches "To" "*.com") {
# Second test is never evaluated, so ${0} is still "0" # The second test is never evaluated, so there are
# still no numbered variables set.
stop; stop;
} }
4. Action set 4. Action set
Syntax: set [MODIFIER] [COMPARATOR] <name: string> <value: string> Syntax: set [MODIFIER] [COMPARATOR] <name: string> <value: string>
The "set" action stores the specified value in the variable The "set" action stores the specified value in the variable
identified by name. The name MUST be a constant string and conform identified by name. The name MUST be a constant string and conform
to the syntax of identifier. An illegal name MUST cause a syntax to the syntax of identifier. An illegal name MUST be detected as a
error. syntax error.
Modifiers are applied on a value before it is stored in the variable. Modifiers are applied on a value before it is stored in the variable.
See next section for details. See next section for details.
The default comparator is "i;ascii-casemap". The comparator only The default comparator is "i;ascii-casemap". The comparator only
affects the result when certain modifiers are used. affects the result when certain modifiers are used.
All variables have global scope: they are visible until processing All variables have global scope: they are visible until processing
stops. Variable names are case insensitive. stops. Variable names are case insensitive.
skipping to change at page 8, line 42 skipping to change at page 9, line 19
"set" does not affect the implicit keep. "set" does not affect the implicit keep.
4.1. Modifiers 4.1. Modifiers
Syntax: ":lower" / ":upper" / ":lowerfirst" / ":upperfirst" / Syntax: ":lower" / ":upper" / ":lowerfirst" / ":upperfirst" /
":length" ":length"
Modifier names are case insensitive. Unknown modifiers MUST yield a Modifier names are case insensitive. Unknown modifiers MUST yield a
syntax error. More than one modifier can be specified, in which case syntax error. More than one modifier can be specified, in which case
they are applied according to this precedence list, highest value they are applied according to this precedence list, largest value
first: first:
+-----------------------------+ +-----------------------------+
| Precedence Modifier | | Precedence Modifier |
+-----------------------------+ +-----------------------------+
| 3 :lower | | 3 :lower |
| :upper | | :upper |
+-----------------------------+ +-----------------------------+
| 2 :lowerfirst | | 2 :lowerfirst |
| :upperfirst | | :upperfirst |
+-----------------------------+ +-----------------------------+
| 1 :length | | 1 :length |
+-----------------------------+ +-----------------------------+
If two or more modifiers of the same precedence are used, they can be If two or more modifiers of the same precedence are used, they can be
applied in any order. applied in any order.
Examples: Examples:
# The value assigned to the variable is printed after the arrow
set "a" "juMBlEd lETteRS"; => "juMBlEd lETteRS" set "a" "juMBlEd lETteRS"; => "juMBlEd lETteRS"
set :length "b" "${a}"; => "15" set :length "b" "${a}"; => "15"
set :lower "b" "${a}"; => "jumbled letters" set :lower "b" "${a}"; => "jumbled letters"
set :lower :comparator "i;octet"
"b" "${a}"; => "juMBlEd lETteRS"
set :upperfirst "b" "${a}"; => "JuMBlEd lETteRS" set :upperfirst "b" "${a}"; => "JuMBlEd lETteRS"
set :upperfirst :lower "b" "${a}"; => "Jumbled letters" set :upperfirst :lower "b" "${a}"; => "Jumbled letters"
4.1.1. Modifier ":length" 4.1.1. Modifier ":length"
The value is the decimal number of characters in the expansion, The value is the decimal number of characters in the expansion,
converted to a string. converted to a string.
4.1.2. Case modifiers 4.1.2. Case modifiers
skipping to change at page 11, line 47 skipping to change at page 12, line 26
Pb 1080, Blindern Pb 1080, Blindern
NO-0316 OSLO NO-0316 OSLO
E-mail: kjetilho@ifi.uio.no E-mail: kjetilho@ifi.uio.no
This information should be added to the list of sieve extensions This information should be added to the list of sieve extensions
given on http://www.iana.org/assignments/sieve-extensions. given on http://www.iana.org/assignments/sieve-extensions.
9. Acknowledgments 9. Acknowledgments
Thanks to Jutta Degener, Ned Freed, Lawrence Greenfield, Mark E. Thanks to Cyrus Daboo, Jutta Degener, Ned Freed, Lawrence Greenfield,
Mallett, Peder Stray and Nigel Swinson for valuable feedback. Mark E. Mallett, Alexey Melnikov, Peder Stray and Nigel Swinson for
valuable feedback.
10. Author's Address 10. Author's Address
Kjetil T. Homme Kjetil T. Homme
University of Oslo University of Oslo
PO Box 1080 PO Box 1080
0316 Oslo, Norway 0316 Oslo, Norway
Phone: +47 9366 0091 Phone: +47 9366 0091
E-mail: kjetilho@ifi.uio.no E-mail: kjetilho@ifi.uio.no
Appendix A. Normative References 11. References
11.1. Normative references
[ABNF] Crocker, D. and Overell, P., "Augmented BNF for Syntax [ABNF] Crocker, D. and Overell, P., "Augmented BNF for Syntax
Specifications: ABNF", RFC 2234, November 1997 Specifications: ABNF", RFC 2234, November 1997
[KEYWORDS] Bradner, S., "Key words for use in RFCs to Indicate [KEYWORDS] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", RFC 2119, March 1997. Requirement Levels", RFC 2119, March 1997.
[RELATIONAL] Segmuller, W., "Sieve Extension: Relational Tests", [RELATIONAL] Segmuller, W., "Sieve Extension: Relational Tests",
RFC 3431, December 2002 RFC 3431, December 2002
[SIEVE] Showalter, T., "Sieve: A Mail Filtering Language", RFC [SIEVE] Showalter, T., "Sieve: A Mail Filtering Language", RFC
3028, January 2001. 3028, January 2001.
[UNICODE] The Unicode Consortium, "The Unicode Standard -- [UNICODE] The Unicode Consortium, "The Unicode Standard --
Worldwide Character Encoding -- Version 1.0", Addison- Worldwide Character Encoding -- Version 1.0", Addison-
Wesley, Volume 1, 1991, Volume 2, 1992. Wesley, Volume 1, 1991, Volume 2, 1992.
[UTF-8] Yergeau, F., "UTF-8, a transformation format of [UTF-8] Yergeau, F., "UTF-8, a transformation format of
Unicode and ISO 10646", RFC 2044, October 1996. Unicode and ISO 10646", RFC 3629, November 2003.
A.1 Informative References 11.2. Informative References
[REGEX] K. Murchison, "Sieve Email Filtering -- Regular [REGEX] K. Murchison, "Sieve Email Filtering -- Regular
Expression Extension", Work in Progress. Expression Extension", Work in Progress.
[SPAMTEST] C. Daboo, "SIEVE Email Filtering: Spamtest and [SPAMTEST] C. Daboo, "SIEVE Email Filtering: Spamtest and
VirusTest Extensions", RFC 3685, February 2004 VirusTest Extensions", RFC 3685, February 2004
Appendix B. Intellectual Property Rights Statement Appendix B. Intellectual Property Rights Statement
The IETF takes no position regarding the validity or scope of any The IETF takes no position regarding the validity or scope of any
 End of changes. 

This html diff was produced by rfcdiff 1.23, available from http://www.levkowetz.com/ietf/tools/rfcdiff/