Network Working Group                                           N. Freed
Request for Comments: 5260                              Sun Microsystems
Category: Standards Track                                      July 2008
        
Network Working Group                                           N. Freed
Request for Comments: 5260                              Sun Microsystems
Category: Standards Track                                      July 2008
        

Sieve Email Filtering: Date and Index Extensions

筛选电子邮件筛选:日期和索引扩展

Status of This Memo

关于下段备忘

This document specifies an Internet standards track protocol for the Internet community, and requests discussion and suggestions for improvements. Please refer to the current edition of the "Internet Official Protocol Standards" (STD 1) for the standardization state and status of this protocol. Distribution of this memo is unlimited.

本文件规定了互联网社区的互联网标准跟踪协议,并要求进行讨论和提出改进建议。有关本协议的标准化状态和状态,请参考当前版本的“互联网官方协议标准”(STD 1)。本备忘录的分发不受限制。

Abstract

摘要

This document describes the "date" and "index" extensions to the Sieve email filtering language. The "date" extension gives Sieve the ability to test date and time values in various ways. The "index" extension provides a means to limit header and address tests to specific instances of header fields when header fields are repeated.

本文档描述了Sieve电子邮件过滤语言的“日期”和“索引”扩展。“日期”扩展使SIVE能够以各种方式测试日期和时间值。“索引”扩展提供了一种方法,在重复标头字段时,将标头和地址测试限制为标头字段的特定实例。

Table of Contents

目录

   1.  Introduction . . . . . . . . . . . . . . . . . . . . . . . . .  2
   2.  Conventions Used in This Document  . . . . . . . . . . . . . .  2
   3.  Capability Identifiers . . . . . . . . . . . . . . . . . . . .  3
   4.  Date Test  . . . . . . . . . . . . . . . . . . . . . . . . . .  3
     4.1.  Zone and Originalzone Arguments  . . . . . . . . . . . . .  4
     4.2.  Date-part Argument . . . . . . . . . . . . . . . . . . . .  4
     4.3.  Comparator Interactions with Date-part Arguments . . . . .  5
     4.4.  Examples . . . . . . . . . . . . . . . . . . . . . . . . .  6
   5.  Currentdate Test . . . . . . . . . . . . . . . . . . . . . . .  6
     5.1.  Examples . . . . . . . . . . . . . . . . . . . . . . . . .  6
   6.  Index Extension  . . . . . . . . . . . . . . . . . . . . . . .  7
     6.1.  Example  . . . . . . . . . . . . . . . . . . . . . . . . .  8
   7.  Security Considerations  . . . . . . . . . . . . . . . . . . .  8
   8.  IANA Considerations  . . . . . . . . . . . . . . . . . . . . .  9
   9.  References . . . . . . . . . . . . . . . . . . . . . . . . . .  9
     9.1.  Normative References . . . . . . . . . . . . . . . . . . .  9
     9.2.  Informative References . . . . . . . . . . . . . . . . . . 10
   Appendix A.  Julian Date Conversions . . . . . . . . . . . . . . . 11
   Appendix B.  Acknowledgements  . . . . . . . . . . . . . . . . . . 12
        
   1.  Introduction . . . . . . . . . . . . . . . . . . . . . . . . .  2
   2.  Conventions Used in This Document  . . . . . . . . . . . . . .  2
   3.  Capability Identifiers . . . . . . . . . . . . . . . . . . . .  3
   4.  Date Test  . . . . . . . . . . . . . . . . . . . . . . . . . .  3
     4.1.  Zone and Originalzone Arguments  . . . . . . . . . . . . .  4
     4.2.  Date-part Argument . . . . . . . . . . . . . . . . . . . .  4
     4.3.  Comparator Interactions with Date-part Arguments . . . . .  5
     4.4.  Examples . . . . . . . . . . . . . . . . . . . . . . . . .  6
   5.  Currentdate Test . . . . . . . . . . . . . . . . . . . . . . .  6
     5.1.  Examples . . . . . . . . . . . . . . . . . . . . . . . . .  6
   6.  Index Extension  . . . . . . . . . . . . . . . . . . . . . . .  7
     6.1.  Example  . . . . . . . . . . . . . . . . . . . . . . . . .  8
   7.  Security Considerations  . . . . . . . . . . . . . . . . . . .  8
   8.  IANA Considerations  . . . . . . . . . . . . . . . . . . . . .  9
   9.  References . . . . . . . . . . . . . . . . . . . . . . . . . .  9
     9.1.  Normative References . . . . . . . . . . . . . . . . . . .  9
     9.2.  Informative References . . . . . . . . . . . . . . . . . . 10
   Appendix A.  Julian Date Conversions . . . . . . . . . . . . . . . 11
   Appendix B.  Acknowledgements  . . . . . . . . . . . . . . . . . . 12
        
1. Introduction
1. 介绍

Sieve [RFC5228] is a language for filtering email messages at or around the time of final delivery. It is designed to be implementable on either a mail client or mail server. It is meant to be extensible, simple, and independent of access protocol, mail architecture, and operating system. It is suitable for running on a mail server where users may not be allowed to execute arbitrary programs, such as on black box Internet Message Access Protocol [RFC3501] servers, as it does not have user-controlled loops or the ability to run external programs.

Sieve[RFC5228]是一种用于在最终交付时或前后过滤电子邮件的语言。它被设计为可以在邮件客户端或邮件服务器上实现。它是可扩展的、简单的,并且独立于访问协议、邮件体系结构和操作系统。它适用于在不允许用户执行任意程序的邮件服务器上运行,例如在黑盒Internet消息访问协议[RFC3501]服务器上,因为它没有用户控制的循环或运行外部程序的能力。

The "date" extension provides a new date test to extract and match date/time information from structured header fields. The date test is similar in concept to the address test specified in [RFC5228], which performs similar operations on addresses in header fields.

“date”扩展提供了一个新的日期测试,用于从结构化标题字段中提取和匹配日期/时间信息。日期测试在概念上与[RFC5228]中指定的地址测试类似,后者对标头字段中的地址执行类似的操作。

The "date" extension also provides a currentdate test that operates on the date and time when the Sieve script is executed.

“date”扩展还提供了一个currentdate测试,该测试在执行Sieve脚本的日期和时间上运行。

Some header fields containing date/time information, e.g., Received:, naturally occur more than once in a single header. In such cases it is useful to be able to restrict the date test to some subset of the fields that are present. For example, it may be useful to apply a date test to the last (earliest) Received: field. Additionally, it may also be useful to apply similar restrictions to either the header or address tests specified in [RFC5228].

某些包含日期/时间信息的标题字段,例如Received:,自然会在单个标题中出现多次。在这种情况下,将日期测试限制在存在的某些字段子集是很有用的。例如,将日期测试应用于最后(最早)接收:字段可能会很有用。此外,对[RFC5228]中指定的报头或地址测试应用类似限制也可能有用。

For this reason, this specification also defines an "index" extension. This extension adds two additional tagged arguments :index and :last to the header, address, and date tests. If present, these arguments specify which occurrence of the named header field is to be tested.

因此,本规范还定义了“索引”扩展。此扩展在标头、地址和日期测试中添加了两个附加的标记参数:index和:last。如果存在,这些参数将指定要测试的命名标头字段的哪个匹配项。

2. Conventions Used in This Document
2. 本文件中使用的公约

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 [RFC2119].

本文件中的关键词“必须”、“不得”、“要求”、“应”、“不应”、“应”、“不应”、“建议”、“可”和“可选”应按照RFC 2119[RFC2119]中所述进行解释。

The terms used to describe the various components of the Sieve language are taken from Section 1.1 of [RFC5228]. Section 2 of the same document describes basic Sieve language syntax and semantics. The date-time syntactic element defined using ABNF notation [RFC5234] in [RFC3339] is also used here.

用于描述筛子语言各组成部分的术语取自[RFC5228]第1.1节。同一文档的第2节描述了基本的Sieve语言语法和语义。这里还使用[RFC3339]中使用ABNF符号[RFC5234]定义的日期-时间语法元素。

3. Capability Identifiers
3. 能力标识符

The capability strings associated with the two extensions defined in this document are "date" and "index".

与本文档中定义的两个扩展相关联的功能字符串是“日期”和“索引”。

4. Date Test
4. 日期测试
   Usage:   date [<":zone" <time-zone: string>> / ":originalzone"]
                 [COMPARATOR] [MATCH-TYPE] <header-name: string>
                 <date-part: string> <key-list: string-list>
        
   Usage:   date [<":zone" <time-zone: string>> / ":originalzone"]
                 [COMPARATOR] [MATCH-TYPE] <header-name: string>
                 <date-part: string> <key-list: string-list>
        

The date test matches date/time information derived from headers containing [RFC2822] date-time values. The date/time information is extracted from the header, shifted to the specified time zone, and the value of the given date-part is determined. The test returns true if the resulting string matches any of the strings specified in the key-list, as controlled by the comparator and match keywords. The date test returns false unconditionally if the specified header field does not exist, the field exists but does not contain a syntactically valid date-time specification, the date-time isn't valid according to the rules of the calendar system (e.g., January 32nd, February 29 in a non-leap year), or the resulting string fails to match any key-list value.

日期测试匹配从包含[RFC2822]日期时间值的标题中派生的日期/时间信息。从报头提取日期/时间信息,移动到指定的时区,并确定给定日期部分的值。如果生成的字符串与由比较器和匹配关键字控制的键列表中指定的任何字符串匹配,则测试返回true。如果指定的标题字段不存在,该字段存在但不包含语法上有效的日期-时间规范,根据日历系统的规则,日期-时间无效(例如,非闰年的1月32日、2月29日),则日期测试无条件返回false,或者结果字符串无法匹配任何键列表值。

The type of match defaults to ":is" and the default comparator is "i;ascii-casemap".

匹配类型默认为“:is”,默认比较器为“i;ascii casemap”。

Unlike the header and address tests, the date test can only be applied to a single header field at a time. If multiple header fields with the same name are present, only the first field that is found is used. (Note, however, that this behavior can be modified with the "index" extension defined below.) These restrictions simplify the test and keep the meaning clear.

与标头和地址测试不同,日期测试一次只能应用于单个标头字段。如果存在多个同名的标题字段,则只使用找到的第一个字段。(但是,请注意,可以使用下面定义的“索引”扩展来修改此行为。)这些限制简化了测试并保持了明确的含义。

The "relational" extension [RFC5231] adds a match type called ":count". The count of a date test is 1 if the specified field exists and contains a valid date; 0, otherwise.

“关系”扩展[RFC5231]添加了一个名为“:count”的匹配类型。如果指定字段存在且包含有效日期,则日期测试的计数为1;否则为0。

Implementations MUST support extraction of RFC 2822 date-time information that either makes up the entire header field (e.g., as it does in a standard Date: header field) or appears at the end of a header field following a semicolon (e.g., as it does in a standard Received: header field). Implementations MAY support extraction of date and time information in RFC2822 or other formats that appears in other positions in header field content. In the case of a field containing more than one date or time value, the last one that appears SHOULD be used.

实现必须支持提取RFC 2822日期时间信息,这些信息要么构成整个标题字段(例如,在标准日期:标题字段中是这样),要么出现在标题字段末尾的分号后面(例如,在标准接收:标题字段中是这样)。实现可能支持以RFC2822或出现在标题字段内容的其他位置的其他格式提取日期和时间信息。如果字段包含多个日期或时间值,则应使用最后一个出现的日期或时间值。

4.1. Zone and Originalzone Arguments
4.1. 区域和原始区域参数

The :originalzone argument specifies that the time zone offset originally in the extracted date-time value should be retained. The :zone argument specifies a specific time zone offset that the date-time value is to be shifted to prior to testing. It is an error to specify both :zone and :originalzone.

:originalzone参数指定应保留最初在提取的日期时间值中的时区偏移。:zone参数指定在测试之前日期时间值要移动到的特定时区偏移量。同时指定:zone和:originalzone是错误的。

The value of time-zone MUST be an offset relative to UTC with the following syntax:

时区的值必须是相对于UTC的偏移量,语法如下:

       time-zone  =  ( "+" / "-" ) 4DIGIT
        
       time-zone  =  ( "+" / "-" ) 4DIGIT
        

The "+" or "-" indicates whether the time-of-day is ahead of (i.e., east of) or behind (i.e., west of) UTC. The first two digits indicate the number of hours difference from Universal Time, and the last two digits indicate the number of minutes difference from Universal Time. Note that this agrees with the RFC 2822 format for time zone offsets, not the ISO 8601 format.

“+”或“-”表示一天中的时间是在UTC之前(即东)还是在UTC之后(即西)。前两位数字表示与世界时相差的小时数,后两位数字表示与世界时相差的分钟数。注意,这与时区偏移的RFC 2822格式一致,而不是ISO 8601格式。

If both the :zone and :originalzone arguments are omitted, the local time zone MUST be used.

如果省略:zone和:originalzone参数,则必须使用本地时区。

4.2. Date-part Argument
4.2. 日期部分参数

The date-part argument specifies a particular part of the resulting date/time value to match against the key-list. Possible case-insensitive values are:

日期部分参数指定结果日期/时间值的特定部分,以与键列表匹配。可能不区分大小写的值包括:

"year" => the year, "0000" .. "9999". "month" => the month, "01" .. "12". "day" => the day, "01" .. "31". "date" => the date in "yyyy-mm-dd" format. "julian" => the Modified Julian Day, that is, the date expressed as an integer number of days since 00:00 UTC on November 17, 1858 (using the Gregorian calendar). This corresponds to the regular Julian Day minus 2400000.5. Sample routines to convert to and from modified Julian dates are given in Appendix A. "hour" => the hour, "00" .. "23". "minute" => the minute, "00" .. "59". "second" => the second, "00" .. "60". "time" => the time in "hh:mm:ss" format. "iso8601" => the date and time in restricted ISO 8601 format. "std11" => the date and time in a format appropriate for use in a Date: header field [RFC2822].

“年”=>年,“0000”。。"9999". “月份”=>月份,“01”。。"12". “天”=>天,“01”。。"31". “日期”=>以“yyyy-mm-dd”格式显示的日期。“朱利安”=>修改后的朱利安日,即自1858年11月17日UTC 00:00(使用公历)起以整数天数表示的日期。这相当于正常的朱利安日减去2400000.5。附录A中给出了与修改后的朱利安日期进行转换的示例例程。“小时”=>小时,“00”。。"23". “分钟”=>分钟,“00”。。"59". “秒”=>秒,“00”。。"60". “time”=>以“hh:mm:ss”格式显示的时间。“iso8601”=>受限ISO 8601格式的日期和时间。“std11”=>日期和时间,格式适合在日期:标题字段[RFC2822]中使用。

"zone" => the time zone in use. If the user specified a time zone with ":zone", "zone" will contain that value. If :originalzone is specified this value will be the original zone specified in the date-time value. If neither argument is specified the value will be the server's default time zone in offset format "+hhmm" or "-hhmm". An offset of 0 (Zulu) always has a positive sign. "weekday" => the day of the week expressed as an integer between "0" and "6". "0" is Sunday, "1" is Monday, etc.

“zone”=>正在使用的时区。如果用户使用“:zone”指定时区,“zone”将包含该值。如果指定了:originalzone,则该值将是在日期时间值中指定的原始区域。如果未指定任何参数,则该值将是偏移量格式为“+hhmm”或“-hhmm”的服务器默认时区。偏移量为0(Zulu)时始终有正号。“weekday”=>以“0”和“6”之间的整数表示的一周中的某一天。“0”是星期天,“1”是星期一等。

The restricted ISO 8601 format is specified by the date-time ABNF production given in [RFC3339], Section 5.6, with the added restrictions that the letters "T" and "Z" MUST be in upper case, and a time zone offset of zero MUST be represented by "Z" and not "+00:00".

受限ISO 8601格式由[RFC3339]第5.6节中给出的日期-时间ABNF生产规定,并增加了字母“T”和“Z”必须大写的限制,并且零时区偏移必须用“Z”而不是“+00:00”表示。

4.3. Comparator Interactions with Date-part Arguments
4.3. 具有日期部分参数的比较器交互

Not all comparators are suitable with all date-part arguments. In general, the date-parts can be compared and tested for equality with either "i;ascii-casemap" (the default) or "i;octet", but there are two exceptions:

并非所有比较器都适用于所有日期部分参数。通常,可以将日期部分与“i;ascii casemap”(默认值)或“i;octet”进行比较和测试,但有两个例外:

julian This is an integer, and may or may not have leading zeros. As such, "i;ascii-numeric" is almost certainly the best comparator to use with it.

这是一个整数,可能有也可能没有前导零。因此,“i;ascii numeric”几乎肯定是最好的比较器。

std11 This is provided as a means to obtain date/time values in a format appropriate for inclusion in email header fields. The wide range of possible syntaxes for a std11 date/time -- which implementations of this extension are free to use when composing a std11 string -- makes this format a poor choice for comparisons. Nevertheless, if a comparison must be performed, this is case-insensitive, and therefore "i;ascii-casemap" needs to be used.

std11这是一种以适合包含在电子邮件标题字段中的格式获取日期/时间值的方法。std11日期/时间的语法范围很广,在编写std11字符串时可以自由使用该扩展的实现,这使得这种格式对于比较来说是一个糟糕的选择。然而,如果必须执行比较,则不区分大小写,因此需要使用“i;ascii casemap”。

"year", "month", "day", "hour", "minute", "second" and "weekday" all use fixed-width string representations of integers, and can therefore be compared with "i;octet", "i;ascii-casemap", and "i;ascii-numeric" with equivalent results.

“年”、“月”、“日”、“小时”、“分钟”、“秒”和“工作日”都使用固定宽度的整数字符串表示,因此可以与“i;八位字节”、“i;ascii casemap”和“i;ascii numeric”进行比较,并得到相同的结果。

"date" and "time" also use fixed-width string representations of integers, and can therefore be compared with "i;octet" and "i;ascii-casemap"; however, "i;ascii-numeric" can't be used with it, as "i;ascii-numeric" doesn't allow for non-digit characters.

“日期”和“时间”也使用固定宽度的整数字符串表示,因此可以与“i;八位字节”和“i;ascii casemap”;但是,“i;ascii数字”不能与它一起使用,因为“i;ascii数字”不允许使用非数字字符。

4.4. Examples
4.4. 例子

The Date: field can be checked to test when the sender claims to have created the message and act accordingly:

可以选中Date:字段以测试发件人何时声明已创建邮件并采取相应行动:

     require ["date", "relational", "fileinto"];
     if allof(header :is "from" "boss@example.com",
              date :value "ge" :originalzone "date" "hour" "09",
              date :value "lt" :originalzone "date" "hour" "17")
     { fileinto "urgent"; }
        
     require ["date", "relational", "fileinto"];
     if allof(header :is "from" "boss@example.com",
              date :value "ge" :originalzone "date" "hour" "09",
              date :value "lt" :originalzone "date" "hour" "17")
     { fileinto "urgent"; }
        

Testing the initial Received: field can provide an indication of when a message was actually received by the local system:

测试初始接收:字段可以提供本地系统实际接收消息的时间指示:

     require ["date", "relational", "fileinto"];
     if anyof(date :is "received" "weekday" "0",
              date :is "received" "weekday" "6")
     { fileinto "weekend"; }
        
     require ["date", "relational", "fileinto"];
     if anyof(date :is "received" "weekday" "0",
              date :is "received" "weekday" "6")
     { fileinto "weekend"; }
        
5. Currentdate Test
5. 当前日期测试
   Usage:   currentdate [":zone" <time-zone: string>]
                        [COMPARATOR] [MATCH-TYPE]
                        <date-part: string>
                        <key-list: string-list>
        
   Usage:   currentdate [":zone" <time-zone: string>]
                        [COMPARATOR] [MATCH-TYPE]
                        <date-part: string>
                        <key-list: string-list>
        

The currentdate test is similar to the date test, except that it operates on the current date/time rather than a value extracted from the message header. In particular, the ":zone" and date-part arguments are the same as those in the date test.

currentdate测试与date测试类似,只是它在当前日期/时间而不是从消息头提取的值上运行。特别是“:zone”和日期部分参数与日期测试中的参数相同。

All currentdate tests in a single Sieve script MUST refer to the same point in time during execution of the script.

在执行脚本期间,单个筛选脚本中的所有currentdate测试都必须引用同一时间点。

The :count value of a currentdate test is always 1.

currentdate测试的:计数值始终为1。

5.1. Examples
5.1. 例子

The simplest use of currentdate is to have an action that only operates at certain times. For example, a user might want to have messages redirected to their pager after business hours and on weekends:

currentdate最简单的用法是有一个只在特定时间运行的操作。例如,用户可能希望在工作时间之后和周末将消息重定向到寻呼机:

     require ["date", "relational"];
     if anyof(currentdate :is "weekday" "0",
              currentdate :is "weekday" "6",
              currentdate :value "lt" "hour" "09",
              currentdate :value "ge" "hour" "17")
     { redirect "pager@example.com"; }
        
     require ["date", "relational"];
     if anyof(currentdate :is "weekday" "0",
              currentdate :is "weekday" "6",
              currentdate :value "lt" "hour" "09",
              currentdate :value "ge" "hour" "17")
     { redirect "pager@example.com"; }
        

Currentdate can be used to set up vacation [RFC5230] responses in advance and to stop response generation automatically:

Currentdate可用于提前设置休假[RFC5230]响应,并自动停止响应生成:

     require ["date", "relational", "vacation"];
     if allof(currentdate :value "ge" "date" "2007-06-30",
              currentdate :value "le" "date" "2007-07-07")
     { vacation :days 7  "I'm away during the first week in July."; }
        
     require ["date", "relational", "vacation"];
     if allof(currentdate :value "ge" "date" "2007-06-30",
              currentdate :value "le" "date" "2007-07-07")
     { vacation :days 7  "I'm away during the first week in July."; }
        

Currentdate may also be used in conjunction with the variables extension to pass time-dependent arguments to other tests and actions. The following Sieve places messages in a folder named according to the current month and year:

Currentdate还可以与variables扩展一起使用,以将依赖于时间的参数传递给其他测试和操作。以下筛选将邮件放置在根据当前月份和年份命名的文件夹中:

     require ["date", "variables", "fileinto"];
     if currentdate :matches "month" "*" { set "month" "${1}"; }
     if currentdate :matches "year"  "*" { set "year"  "${1}"; }
     fileinto "${month}-${year}";
        
     require ["date", "variables", "fileinto"];
     if currentdate :matches "month" "*" { set "month" "${1}"; }
     if currentdate :matches "year"  "*" { set "year"  "${1}"; }
     fileinto "${month}-${year}";
        

Finally, currentdate can be used in conjunction with the editheader extension to insert a header-field containing date/time information:

最后,currentdate可与editheader扩展一起使用,以插入包含日期/时间信息的标题字段:

      require ["variables", "date", "editheader"];
      if currentdate :matches "std11" "*"
        {addheader "Processing-date" "${0}";}
        
      require ["variables", "date", "editheader"];
      if currentdate :matches "std11" "*"
        {addheader "Processing-date" "${0}";}
        
6. Index Extension
6. 索引扩展

The "index" extension, if specified, adds optional :index and :last arguments to the header, address, and date tests as follows:

“index”扩展名(如果指定)将向标头、地址和日期测试添加可选的:index和:last参数,如下所示:

   Syntax:   date [":index" <fieldno: number> [":last"]]
                  [<":zone" <time-zone: string>> / ":originalzone"]
                  [COMPARATOR] [MATCH-TYPE] <header-name: string>
                  <date-part: string> <key-list: string-list>
        
   Syntax:   date [":index" <fieldno: number> [":last"]]
                  [<":zone" <time-zone: string>> / ":originalzone"]
                  [COMPARATOR] [MATCH-TYPE] <header-name: string>
                  <date-part: string> <key-list: string-list>
        
   Syntax:   header [":index" <fieldno: number> [":last"]]
                    [COMPARATOR] [MATCH-TYPE]
                    <header-names: string-list> <key-list: string-list>
        
   Syntax:   header [":index" <fieldno: number> [":last"]]
                    [COMPARATOR] [MATCH-TYPE]
                    <header-names: string-list> <key-list: string-list>
        
   Syntax:   address [":index" <fieldno: number> [":last"]]
                     [ADDRESS-PART] [COMPARATOR] [MATCH-TYPE]
                     <header-list: string-list> <key-list: string-list>
        
   Syntax:   address [":index" <fieldno: number> [":last"]]
                     [ADDRESS-PART] [COMPARATOR] [MATCH-TYPE]
                     <header-list: string-list> <key-list: string-list>
        

If :index <fieldno> is specified, the attempts to match a value are limited to the header field fieldno (beginning at 1, the first named header field). If :last is also specified, the count is backwards; 1 denotes the last named header field, 2 the second to last, and so on. Specifying :last without :index is an error.

如果指定了:index<fieldno>,则匹配值的尝试仅限于标头字段fieldno(从1开始,第一个命名的标头字段)。如果还指定了:last,则计数向后;1表示最后命名的头字段,2表示倒数第二个,依此类推。指定:last而不指定:index是错误的。

:index only counts separate header fields, not multiple occurrences within a single field. In particular, :index cannot be used to test a specific address in an address list contained within a single header field.

:索引仅统计单独的标题字段,而不是单个字段中的多次出现。特别是,:index不能用于测试单个标头字段中包含的地址列表中的特定地址。

Both header and address allow the specification of more than one header field name. If more than one header field name is specified, all the named header fields are counted in the order specified by the header-list.

标头和地址都允许指定多个标头字段名。如果指定了多个标题字段名称,则所有已命名的标题字段将按标题列表指定的顺序计数。

6.1. Example
6.1. 实例

Mail delivery may involve multiple hops, resulting in the Received: field containing information about when a message first entered the local administrative domain being the second or subsequent field in the message. As long as the field offset is consistent, it can be tested:

邮件传递可能涉及多个跃点,导致包含有关邮件何时首次进入本地管理域的信息的Received:字段成为邮件中的第二个或后续字段。只要字段偏移量一致,就可以进行测试:

     # Implement the Internet-Draft cutoff date check assuming the
     # second Received: field specifies when the message first
     # entered the local email infrastructure.
     require ["date", "relational", "index"];
     if date :value "gt" :index 2 :zone "-0500" "received"
             "iso8601" "2007-02-26T09:00:00-05:00",
     { redirect "aftercutoff@example.org"; }
        
     # Implement the Internet-Draft cutoff date check assuming the
     # second Received: field specifies when the message first
     # entered the local email infrastructure.
     require ["date", "relational", "index"];
     if date :value "gt" :index 2 :zone "-0500" "received"
             "iso8601" "2007-02-26T09:00:00-05:00",
     { redirect "aftercutoff@example.org"; }
        
7. Security Considerations
7. 安全考虑

The facilities defined here, like the facilities in the base Sieve specification, operate on message header information that can easily be forged. Note, however, that some fields are inherently more reliable than others. For example, the Date: field is typically inserted by the message sender and can be altered at any point. By contrast, the uppermost Received: field is typically inserted by the local mail system and is therefore difficult for the sender or an intermediary to falsify.

这里定义的设施,与基本筛规范中的设施一样,对容易伪造的消息头信息进行操作。但是,请注意,某些字段本质上比其他字段更可靠。例如,日期:字段通常由消息发送者插入,并且可以在任何时候进行更改。相比之下,最上面的Received:字段通常由本地邮件系统插入,因此发件人或中间人很难伪造。

Use of the currentdate test makes script behavior inherently less predictable and harder to analyze. This may have consequences for systems that use script analysis to try and spot problematic scripts.

currentdate测试的使用使得脚本行为本质上不太可预测,更难分析。这可能会对使用脚本分析来尝试发现问题脚本的系统产生影响。

All of the security considerations given in the base Sieve specification also apply to these extensions.

基本筛规范中给出的所有安全注意事项也适用于这些扩展。

8. IANA Considerations
8. IANA考虑

The following templates specify the IANA registrations of the two Sieve extensions specified in this document:

以下模板规定了本文件中规定的两个筛网扩展的IANA注册:

To: iana@iana.org Subject: Registration of new Sieve extensions

致:iana@iana.org主题:新筛网扩展的注册

      Capability name: date
      Description:     The "date" extension gives Sieve the ability
                       to test date and time values.
      RFC number:      RFC 5260
      Contact address: Sieve discussion list <ietf-mta-filters@imc.org>
        
      Capability name: date
      Description:     The "date" extension gives Sieve the ability
                       to test date and time values.
      RFC number:      RFC 5260
      Contact address: Sieve discussion list <ietf-mta-filters@imc.org>
        

Capability name: index Description: The "index" extension provides a means to limit header and address tests to specific instances when more than one field of a given type is present. RFC number: RFC 5260 Contact address: Sieve discussion list <ietf-mta-filters@imc.org>

功能名称:索引描述:“索引”扩展提供了一种方法,当给定类型的多个字段存在时,可以将头和地址测试限制到特定实例。RFC编号:RFC 5260联系地址:筛讨论列表<ietf mta-filters@imc.org>

9. References
9. 工具书类
9.1. Normative References
9.1. 规范性引用文件

[CALGO199] Tantzen, R., "Algorithm 199: Conversions Between Calendar Date and Julian Day Number", Collected Algorithms from CACM 199.

[CALGO199]Tantzen,R.,“算法199:日历日期和朱利安日数之间的转换”,从CACM 199收集算法。

[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997.

[RFC2119]Bradner,S.,“RFC中用于表示需求水平的关键词”,BCP 14,RFC 2119,1997年3月。

[RFC2822] Resnick, P., "Internet Message Format", RFC 2822, April 2001.

[RFC2822]Resnick,P.,“互联网信息格式”,RFC 2822,2001年4月。

[RFC3339] Klyne, G., Ed. and C. Newman, "Date and Time on the Internet: Timestamps", RFC 3339, July 2002.

[RFC3339]Klyne,G.,Ed.和C.Newman,“互联网上的日期和时间:时间戳”,RFC33392002年7月。

[RFC5228] Guenther, P. and T. Showalter, "Sieve: An Email Filtering Language", RFC 5228, January 2008.

[RFC5228]Guenther,P.和T.Showalter,“筛选:电子邮件过滤语言”,RFC 5228,2008年1月。

[RFC5231] Segmuller, W. and B. Leiba, "Sieve Email Filtering: Relational Extension", RFC 5231, January 2008.

[RFC5231]Segmuler,W.和B.Leiba,“筛选电子邮件过滤:关系扩展”,RFC 52312008年1月。

[RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax Specifications: ABNF", STD 68, RFC 5234, January 2008.

[RFC5234]Crocker,D.和P.Overell,“语法规范的扩充BNF:ABNF”,STD 68,RFC 5234,2008年1月。

9.2. Informative References
9.2. 资料性引用

[RFC3501] Crispin, M., "INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1", RFC 3501, March 2003.

[RFC3501]Crispin,M.,“互联网消息访问协议-版本4rev1”,RFC 35012003年3月。

[RFC5230] Showalter, T. and N. Freed, "Sieve Email Filtering: Vacation Extension", RFC 5230, January 2008.

[RFC5230]Showalter,T.和N.Freed,“筛选电子邮件过滤:假期延长”,RFC 5230,2008年1月。

Appendix A. Julian Date Conversions
附录A.朱利安日期转换

The following C routines show how to translate day/month/year information to and from modified Julian dates. These routines are straightforward translations of the Algol routines specified in CACM Algorithm 199 [CALGO199].

下面的C例程显示了如何将日/月/年信息与修改后的Julian日期进行转换。这些例程是CACM算法199[CALGO199]中指定的Algol例程的直接翻译。

Given the day, month, and year, jday returns the modified Julian date.

给定日期、月份和年份,jday返回修改后的Julian日期。

   int jday(int year, int month, int day)
   {
       int j, c, ya;
        
   int jday(int year, int month, int day)
   {
       int j, c, ya;
        
       if (month > 2)
           month -= 3;
       else
       {
           month += 9;
           year--;
       }
       c = year / 100;
       ya = year - c * 100;
       return (c * 146097 / 4 + ya * 1461 / 4 + (month * 153 + 2) / 5 +
               day + 1721119);
   }
        
       if (month > 2)
           month -= 3;
       else
       {
           month += 9;
           year--;
       }
       c = year / 100;
       ya = year - c * 100;
       return (c * 146097 / 4 + ya * 1461 / 4 + (month * 153 + 2) / 5 +
               day + 1721119);
   }
        

Given j, the modified Julian date, jdate returns the day, month, and year.

给定修改后的朱利安日期j,jdate返回日、月和年。

   void jdate(int j, int *year, int *month, int *day)
   {
       int y, m, d;
        
   void jdate(int j, int *year, int *month, int *day)
   {
       int y, m, d;
        
       j -= 1721119;
       y = (j * 4 - 1) / 146097;
       j = j * 4 - y * 146097 - 1;
       d = j / 4;
       j = (d * 4 + 3) / 1461;
       d = d * 4 - j * 1461 + 3;
       d = (d + 4) / 4;
       m = (d * 5 - 3) / 153;
       d = d * 5 - m * 153 - 3;
       *day = (d + 5) / 5;
       *year = y * 100 + j;
       if (m < 10)
           *month = m + 3;
       else
       {
           *month = m - 9;
           *year += 1;
       }
   }
        
       j -= 1721119;
       y = (j * 4 - 1) / 146097;
       j = j * 4 - y * 146097 - 1;
       d = j / 4;
       j = (d * 4 + 3) / 1461;
       d = d * 4 - j * 1461 + 3;
       d = (d + 4) / 4;
       m = (d * 5 - 3) / 153;
       d = d * 5 - m * 153 - 3;
       *day = (d + 5) / 5;
       *year = y * 100 + j;
       if (m < 10)
           *month = m + 3;
       else
       {
           *month = m - 9;
           *year += 1;
       }
   }
        
Appendix B. Acknowledgements
附录B.确认书

Dave Cridland contributed the text describing the proper comparators to use with different date-parts. Cyrus Daboo, Frank Ellerman, Alexey Melnikov, Chris Newman, Dilyan Palauzov, and Aaron Stone provided helpful suggestions and corrections.

Dave Cridland提供了描述用于不同日期部分的适当比较器的文本。赛勒斯·达布、弗兰克·埃勒曼、阿列克西·梅尔尼科夫、克里斯·纽曼、迪扬·帕劳佐夫和亚伦·斯通提供了有益的建议和更正。

Author's Address

作者地址

Ned Freed Sun Microsystems 800 Royal Oaks Monrovia, CA 91016-6347 USA

Ned Freed Sun Microsystems 800 Royal Oaks Monrovia,加利福尼亚州91016-6347美国

   Phone: +1 909 457 4293
   EMail: ned.freed@mrochek.com
        
   Phone: +1 909 457 4293
   EMail: ned.freed@mrochek.com
        

Full Copyright Statement

完整版权声明

Copyright (C) The IETF Trust (2008).

版权所有(C)IETF信托基金(2008年)。

This document is subject to the rights, licenses and restrictions contained in BCP 78, and except as set forth therein, the authors retain all their rights.

本文件受BCP 78中包含的权利、许可和限制的约束,除其中规定外,作者保留其所有权利。

This document and the information contained herein are provided on an "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY, THE IETF TRUST AND THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.

本文件及其包含的信息以“原样”为基础提供,贡献者、他/她所代表或赞助的组织(如有)、互联网协会、IETF信托基金和互联网工程任务组不承担任何明示或暗示的担保,包括但不限于任何保证,即使用本文中的信息不会侵犯任何权利,或对适销性或特定用途适用性的任何默示保证。

Intellectual Property

知识产权

The IETF takes no position regarding the validity or scope of any Intellectual Property Rights or other rights that might be claimed to pertain to the implementation or use of the technology described in 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 made any independent effort to identify any such rights. Information on the procedures with respect to rights in RFC documents can be found in BCP 78 and BCP 79.

IETF对可能声称与本文件所述技术的实施或使用有关的任何知识产权或其他权利的有效性或范围,或此类权利下的任何许可可能或可能不可用的程度,不采取任何立场;它也不表示它已作出任何独立努力来确定任何此类权利。有关RFC文件中权利的程序信息,请参见BCP 78和BCP 79。

Copies of IPR disclosures made to the IETF Secretariat and any 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 such proprietary rights by implementers or users of this specification can be obtained from the IETF on-line IPR repository at http://www.ietf.org/ipr.

向IETF秘书处披露的知识产权副本和任何许可证保证,或本规范实施者或用户试图获得使用此类专有权利的一般许可证或许可的结果,可从IETF在线知识产权存储库获取,网址为http://www.ietf.org/ipr.

The IETF invites any interested party to bring to its attention any copyrights, patents or patent applications, or other proprietary rights that may cover technology that may be required to implement this standard. Please address the information to the IETF at ietf-ipr@ietf.org.

IETF邀请任何相关方提请其注意任何版权、专利或专利申请,或其他可能涵盖实施本标准所需技术的专有权利。请将信息发送至IETF的IETF-ipr@ietf.org.