draft-ietf-sieve-variables-02.txt   draft-ietf-sieve-variables-03.txt 
Network Working Group K. T. Homme Network Working Group K. T. Homme
Updates: 3028 Updates: 3028
Document: draft-ietf-sieve-variables-02.txt University of Oslo Document: draft-ietf-sieve-variables-03.txt University of Oslo
Expires Oct 5, 2005 5 Apr 2005 Expires Oct 28, 2005 28 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 3978. 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 becomes aware will be disclosed, in accordance with
RFC 3668. Section 6 of BCP 79.
Internet-Drafts are working documents of the Internet Engineering Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF), its areas, and its working groups. Note that Task Force (IETF), its areas, and its working groups. Note that
other groups may also distribute working documents as Internet- other groups may also distribute working documents as Internet-
Drafts. Drafts.
Internet-Drafts are draft documents valid for a maximum of six months Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress." material or to cite them other than as "work in progress."
skipping to change at page 4, line 42 skipping to change at page 4, line 42
b) added example of SET with a comparator. b) added example of SET with a comparator.
c) changed "highest value" to the less ambiguous "largest value". c) changed "highest value" to the less ambiguous "largest value".
d) updated reference to [UTF-8]. d) updated reference to [UTF-8].
e) allow numbered variables in namespaces. e) allow numbered variables in namespaces.
f) change ${0} to mean the complete match. f) change ${0} to mean the complete match.
0.3. Open Issues 0.2.8. Changes since -02
Should we allow all-digit namespace components? e.g., array.var.2.3 a) explicitly state compatibility with actions in base spec.
to provide array variables.
b) "numbered variables" are now called "match variables".
c) clarify definition of "match variable".
d) it's not the whole namespace which should match the extension
keyword, only the first component.
e) allow level 2 and above of the namespace specification to be all-
digit.
f) combining :upper and :lower etc. is a now syntax error.
g) allow SET to set variables in namespaces if the extension allows
it.
0.3. Open Issues
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
skipping to change at page 5, line 43 skipping to change at page 6, line 17
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 = "${" *namespace variable-name "}" variable-ref = "${" [namespace] variable-name "}"
namespace = identifier "." *sub-namespace
sub-namespace = variable-name "."
variable-name = num-variable / identifier variable-name = num-variable / 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.}"
skipping to change at page 6, line 27 skipping to change at page 6, line 46
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.
Strings where no variable substitutions take place are referred to as Strings where no variable substitutions take place are referred to as
constant strings. Future extensions may specify that passing non- constant strings. Future extensions may specify that passing non-
constant strings as arguments to its actions or tests is an error. constant strings as arguments to its actions or tests is an error.
Namespaces are meant for future extensions which make internal state Namespaces are meant for future extensions which make internal state
available through variables. These variables SHOULD be put in a available through variables. These variables SHOULD be put in a
namespace with the same name as its capability string. Notice that namespace whose first component is the same as its capability string.
the user can not specify a namespace when setting variables with SET. Such extensions SHOULD state which, if any, of the variables in its
namespace are modifiable with the "set" action.
References to namespaces without a prior require statement for the
relevant extension MUST cause a syntax error.
Tests or actions in future extensions may need to access the Tests or actions in future extensions may need to access the
unexpanded version of the string argument and, e.g., do the expansion unexpanded version of the string argument and, e.g., do the expansion
after setting variables in its namespace. The design of the after setting variables in its namespace. The design of the
implementation should allow this. implementation should allow this.
3.1. Quoting 3.1. Quoting
The semantics of quoting using backslash are not changed: backslash The semantics of quoting using backslash are not changed: backslash
quoting is resolved before doing variable substitution. quoting is resolved before doing variable substitution.
skipping to change at page 7, line 9 skipping to change at page 7, line 30
expansion of variable foo. expansion of variable foo.
If it is required to include a character sequence such as "${beep}" If it is required to include a character sequence such as "${beep}"
verbatim in a text literal, the user can define a variable to verbatim in a text literal, the user can define a variable to
circumvent expansion to the empty string. circumvent expansion to the empty string.
Example: Example:
set "dollar" "$"; set "dollar" "$";
set "text" "regarding ${dollar}{beep}"; set "text" "regarding ${dollar}{beep}";
3.2. Numbered variables 3.2. Match variables
The decimal value of the numbered variable name will index the list A "match variable" has a name consisting only of decimal digits and
of matching strings from the most recently evaluated successful match has no namespace component.
of type ":matches" or ":regex" (see [REGEX]). The list is empty if
no match has been successful. The decimal value of the match variable name will index the list of
matching strings from the most recently evaluated successful match of
type ":matches" or ":regex" (see [REGEX]). The list is empty if no
match has been successful.
For ":matches", the list will contain one string for each wildcard For ":matches", the list will contain one string for each wildcard
("?" 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).
skipping to change at page 8, line 19 skipping to change at page 8, line 44
fileinfo "lists.${1}"; stop; fileinfo "lists.${1}"; stop;
} }
if address :matches ["To", "Cc"] ["coyote@**.com", if address :matches ["To", "Cc"] ["coyote@**.com",
"wile@**.com"] { "wile@**.com"] {
# ${0} is the matching address. # ${0} is the matching address.
# ${1} is always the empty string. # ${1} is always the empty string.
fileinto "business.${2}"; stop; fileinto "business.${2}"; stop;
} else { } else {
# Control wouldn't reach this block if any match was # Control wouldn't reach this block if any match was
# successful, so no numbered variables are set at this # successful, so no match variables are set at this
# point. # point.
} }
if anyof (true, address :domain :matches "To" "*.com") { if anyof (true, address :domain :matches "To" "*.com") {
# The second test is never evaluated, so there are # The second test is never evaluated, so there are
# still no numbered variables set. # still no match 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 be detected as a to the syntax of variable-name. Match variables can not be set. A
syntax error. namespace can not be used unless an extension explicitly allows its
use in "set". An invalid name MUST be detected as a 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.
Example: Example:
set "honorific" "Mr"; set "honorific" "Mr";
set "first_name" "Wile"; set "first_name" "Wile";
set "last_name" "Coyote"; set "last_name" "Coyote";
set "vacation" text: set "vacation" text:
Dear ${HONORIFIC} ${last_name}, Dear ${HONORIFIC} ${last_name},
I'm out, please leave a message after the meep. I'm out, please leave a message after the meep.
. .
; ;
"set" does not affect the implicit keep. "set" does not affect the implicit keep. It is compatible with all
actions defined in [SIEVE].
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, largest value they are applied according to this precedence list, largest value
first: first:
+-----------------------------+ +-----------------------------+
| Precedence Modifier | | Precedence Modifier |
+-----------------------------+ +-----------------------------+
| 3 :lower | | 30 :lower |
| :upper | | :upper |
+-----------------------------+ +-----------------------------+
| 2 :lowerfirst | | 20 :lowerfirst |
| :upperfirst | | :upperfirst |
+-----------------------------+ +-----------------------------+
| 1 :length | | 10 :length |
+-----------------------------+ +-----------------------------+
If two or more modifiers of the same precedence are used, they can be Using two or more modifiers of the same precedence is a syntax error.
applied in any order.
Examples: Examples:
# The value assigned to the variable is printed after the arrow # 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" set :lower :comparator "i;octet"
"b" "${a}"; => "juMBlEd lETteRS" "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"
skipping to change at page 11, line 24 skipping to change at page 11, line 47
An implementation of this draft MUST support at least 128 distinct An implementation of this draft MUST support at least 128 distinct
variables. The supported length of variable names MUST be at least variables. The supported length of variable names MUST be at least
32 characters. Each variable MUST be able to hold at least 4000 32 characters. Each variable MUST be able to hold at least 4000
characters. Attempts to set the variable to a value larger than what characters. Attempts to set the variable to a value larger than what
the implementation supports SHOULD be reported as an error at the implementation supports SHOULD be reported as an error at
compile-time if possible. If the attempt is discovered during run- compile-time if possible. If the attempt is discovered during run-
time, the value SHOULD be truncated and it MUST NOT be treated as an time, the value SHOULD be truncated and it MUST NOT be treated as an
error. error.
Numbered variables ${1} through ${9} MUST be supported. References Match variables ${1} through ${9} MUST be supported. References to
to higher indices than the implementation supports MUST be treated as higher indices than the implementation supports MUST be treated as a
a syntax error which SHOULD be discovered at compile-time. syntax error which SHOULD be discovered at compile-time.
7. Security Considerations 7. Security Considerations
When numbered variables are used, and the author of the script isn't When match variables are used, and the author of the script isn't
careful, strings can contain arbitrary values controlled by the careful, strings can contain arbitrary values controlled by the
sender of the e-mail. sender of the e-mail.
The introduction of variables makes advanced decision making easier The introduction of variables makes advanced decision making easier
to write, but since no looping construct is provided, all Sieve to write, but since no looping construct is provided, all Sieve
scripts will terminate in an orderly manner. scripts will terminate in an orderly manner.
Sieve filtering should not be relied on as a security measure against Sieve filtering should not be relied on as a security measure against
hostile e-mail messages. Sieve is designed to do simple, mostly hostile e-mail messages. Sieve is designed to do simple, mostly
static tests, and is not suitable for use as a spam or virus checker, static tests, and is not suitable for use as a spam or virus checker,
skipping to change at page 14, line 21 skipping to change at page 14, line 45
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
Intellectual Property Intellectual Property
The IETF takes no position regarding the validity or scope of any The IETF takes no position regarding the validity or scope of any
Intellectual Property Rights or other rights that might be claimed to Intellectual Property Rights or other rights that might be claimed to
pertain to the implementation or use of the technology described in pertain to the implementation or use of the technology described in
this document or the extent to which any license under such rights this document or the extent to which any license under such rights
might or might not be available; nor does it represent that it has might or might not be available; nor does it represent that it has
made any independent effort to identify any such rights. Information made any independent effort to identify any such rights. Information
on the IETF's procedures with respect to rights in IETF Documents can on the procedures with respect to rights in RFC documents can be
be found in BCP 78 and BCP 79. found in BCP 78 and BCP 79.
Copies of IPR disclosures made to the IETF Secretariat and any Copies of IPR disclosures made to the IETF Secretariat and any
assurances of licenses to be made available, or the result of an assurances of licenses to be made available, or the result of an
attempt made to obtain a general license or permission for the use of attempt made to obtain a general license or permission for the use of
such proprietary rights by implementers or users of this such proprietary rights by implementers or users of this
specification can be obtained from the IETF on-line IPR repository at specification can be obtained from the IETF on-line IPR repository at
http://www.ietf.org/ipr. http://www.ietf.org/ipr.
The IETF invites any interested party to bring to its attention any The IETF invites any interested party to bring to its attention any
copyrights, patents or patent applications, or other proprietary copyrights, patents or patent applications, or other proprietary
 End of changes. 

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