Network Working Group                                       W. Segmuller
Request for Comment: 3431                IBM T.J. Watson Research Center
Category: Standards Track                                  December 2002
        
Network Working Group                                       W. Segmuller
Request for Comment: 3431                IBM T.J. Watson Research Center
Category: Standards Track                                  December 2002
        

Sieve Extension: Relational Tests

筛扩展:关系测试

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)。本备忘录的分发不受限制。

Copyright Notice

版权公告

Copyright (C) The Internet Society (2002). All Rights Reserved.

版权所有(C)互联网协会(2002年)。版权所有。

Abstract

摘要

This document describes the RELATIONAL extension to the Sieve mail filtering language defined in RFC 3028. This extension extends existing conditional tests in Sieve to allow relational operators. In addition to testing their content, it also allows for testing of the number of entities in header and envelope fields.

本文档描述RFC 3028中定义的筛邮件过滤语言的关系扩展。此扩展扩展扩展了Sieve中现有的条件测试,以允许使用关系运算符。除了测试其内容外,它还允许测试标头和信封字段中的实体数量。

1 Introduction

1导言

Sieve [SIEVE] is a language for filtering e-mail messages at 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 Messages Access Protocol (IMAP) servers, as it has no variables, loops, nor the ability to shell out to external programs.

Sieve[Sieve]是一种用于在最终传递时过滤电子邮件的语言。它被设计为可以在邮件客户端或邮件服务器上实现。它是可扩展的、简单的,并且独立于访问协议、邮件体系结构和操作系统。它适合在不允许用户执行任意程序的邮件服务器上运行,例如在黑匣子Internet Messages Access Protocol(IMAP)服务器上,因为它没有变量、循环,也不能向外推出程序。

The RELATIONAL extension provides relational operators on the address, envelope, and header tests. This extension also provides a way of counting the entities in a message header or address field.

关系扩展为地址、信封和头测试提供了关系运算符。此扩展还提供了一种对消息头或地址字段中的实体进行计数的方法。

With this extension, the sieve script may now determine if a field is greater than or less than a value instead of just equivalent. One use is for the x-priority field: move messages with a priority greater than 3 to the "work on later" folder. Mail could also be sorted by the from address. Those userids that start with 'a'-'m' go to one folder, and the rest go to another folder.

通过此扩展,sieve脚本现在可以确定字段是否大于或小于某个值,而不仅仅是等效值。一个用途是用于x优先级字段:将优先级大于3的邮件移动到“以后工作”文件夹。邮件也可以按发件人地址排序。那些以“a”-“m”开头的用户标识进入一个文件夹,其余的进入另一个文件夹。

The sieve script can also determine the number of fields in the header, or the number of addresses in a recipient field. For example: are there more than 5 addresses in the to and cc fields.

sieve脚本还可以确定标头中的字段数,或收件人字段中的地址数。例如:“收件人”和“抄送”字段中的地址是否超过5个。

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 BCP 14, RFC 2119.

本文件中的关键词“必须”、“不得”、“要求”、“应”、“不应”、“应”、“不应”、“建议”、“可”和“可选”应按照BCP 14、RFC 2119中的说明进行解释。

Conventions for notations are as in [SIEVE] section 1.1, including the use of [KEYWORDS] and "Syntax:" label for the definition of action and tagged arguments syntax, and the use of [ABNF].

注释惯例如[SIFE]第1.1节所述,包括使用[KEYWORDS]和“Syntax:”标签定义动作和标记参数语法,以及使用[ABNF]。

The capability string associated with extension defined in this document is "relational".

与本文档中定义的扩展相关联的功能字符串是“relational”。

3 Comparators

3个比较器

This document does not define any comparators or exempt any comparators from the require clause. Any comparator used, other than "i;octet" and "i;ascii-casemap", MUST be declared a require clause as defined in [SIEVE].

本文件不定义任何比较器,也不免除任何比较器的要求条款。使用的任何比较器,除“i;八位字节”和“i;ascii casemap”外,必须声明为[SIEVE]中定义的require子句。

The "i;ascii-numeric" comparator, as defined in [ACAP], MUST be supported for any implementation of this extension. The comparator "i;ascii-numeric" MUST support at least 32 bit unsigned integers.

此扩展的任何实现都必须支持[ACAP]中定义的“i;ascii数字”比较器。比较器“i;ascii数字”必须至少支持32位无符号整数。

Larger integers MAY be supported. Note: the "i;ascii-numeric" comparator does not support negative numbers.

可能支持较大的整数。注:“i;ascii数字”比较器不支持负数。

4 Match Type

4火柴类型

This document defines two new match types. They are the VALUE match type and the COUNT match type.

本文档定义了两种新的匹配类型。它们是值匹配类型和计数匹配类型。

The syntax is:

语法是:

        MATCH-TYPE =/ COUNT / VALUE
        
        MATCH-TYPE =/ COUNT / VALUE
        

COUNT = ":count" relational-match

COUNT=“:COUNT”关系匹配

VALUE = ":value" relational-match

VALUE=“:VALUE”关系匹配

        relational-match = DQUOTE ( "gt" / "ge" / "lt"
                                    / "le" / "eq" / "ne" ) DQUOTE
        
        relational-match = DQUOTE ( "gt" / "ge" / "lt"
                                    / "le" / "eq" / "ne" ) DQUOTE
        
4.1 Match Type Value
4.1 匹配类型值

The VALUE match type does a relational comparison between strings.

值匹配类型在字符串之间进行关系比较。

The VALUE match type may be used with any comparator which returns sort information.

值匹配类型可与返回排序信息的任何比较器一起使用。

Leading and trailing white space MUST be removed from the value of the message for the comparison. White space is defined as

为了进行比较,必须从消息的值中删除前导空格和尾随空格。空白被定义为

SP / HTAB / CRLF

SP/HTAB/CRLF

A value from the message is considered the left side of the relation. A value from the test expression, the key-list for address, envelope, and header tests, is the right side of the relation.

消息中的值被视为关系的左侧。测试表达式(地址、信封和标头测试的键列表)中的值位于关系的右侧。

If there are multiple values on either side or both sides, the test is considered true, if any pair is true.

如果任意一侧或两侧都有多个值,则如果任何一对值为真,则认为测试为真。

4.2 Match Type Count
4.2 匹配类型计数

The COUNT match type first determines the number of the specified entities in the message and does a relational comparison of the number of entities to the values specified in the test expression.

计数匹配类型首先确定消息中指定实体的数量,并将实体数量与测试表达式中指定的值进行关系比较。

The COUNT match type SHOULD only be used with numeric comparators.

计数匹配类型只能与数字比较器一起使用。

The Address Test counts the number of recipients in the specified fields. Group names are ignored.

地址测试统计指定字段中的收件人数。组名将被忽略。

The Envelope Test counts the number of recipients in the specified envelope parts. The envelope "to" will always have only one entry, which is the address of the user for whom the sieve script is running. There is no way a sieve script can determine if the message was actually sent to someone else using this test. The envelope "from" will be 0 if the MAIL FROM is blank, or 1 if MAIL FROM is not blank.

信封测试统计指定信封部分中的收件人数量。信封“to”始终只有一个条目,即正在为其运行筛选脚本的用户的地址。sieve脚本无法确定消息是否实际发送给使用此测试的其他人。如果邮件发件人为空,则信封“发件人”将为0;如果邮件发件人不为空,则信封“发件人”将为1。

The Header Test counts the total number of instances of the specified fields. This does not count individual addresses in the "to", "cc", and other recipient fields.

标头测试统计指定字段的实例总数。这不包括“收件人”、“抄送”和其他收件人字段中的单个地址。

In all cases, if more than one field name is specified, the counts for all specified fields are added together to obtain the number for comparison. Thus, specifying ["to", "cc"] in an address COUNT test, comparing the total number of "to" and "cc" addresses; if separate counts are desired, they must be done in two comparisons, perhaps joined by "allof" or "anyof".

在所有情况下,如果指定了多个字段名,则将所有指定字段的计数相加,以获得用于比较的数字。因此,在地址计数测试中指定[“to”,“cc”],比较“to”和“cc”地址的总数;如果需要单独的计数,则必须在两次比较中进行,可能加上“allof”或“anyof”。

5 Security Considerations

5安全考虑

Security considerations are discussed in [SIEVE].

[SIFE]中讨论了安全注意事项。

An implementation MUST ensure that the test for envelope "to" only reflects the delivery to the current user. It MUST not be possible for a user to determine if this message was delivered to someone else using this test.

实现必须确保信封“to”的测试只反映对当前用户的交付。用户不能确定此消息是否已通过此测试传递给其他人。

6 Example

6例

Using the message:

使用消息:

      received: ...
      received: ...
      subject: example
      to: foo@example.com.invalid, baz@example.com.invalid
      cc: qux@example.com.invalid
        
      received: ...
      received: ...
      subject: example
      to: foo@example.com.invalid, baz@example.com.invalid
      cc: qux@example.com.invalid
        

The test:

测试:

address :count "ge" :comparator "i;ascii-numeric" ["to", "cc"] ["3"]

地址:计数“ge”:比较器“i;ascii数字”[“至”,“抄送”][“3”]

would be true and the test

将是真实的和测试

         anyof ( address :count "ge" :comparator "i;ascii-numeric"
                         ["to"] ["3"],
                 address :count "ge" :comparator "i;ascii-numeric"
                         ["cc"] ["3"] )
        
         anyof ( address :count "ge" :comparator "i;ascii-numeric"
                         ["to"] ["3"],
                 address :count "ge" :comparator "i;ascii-numeric"
                         ["cc"] ["3"] )
        

would be false.

这是错误的。

To check the number of received fields in the header, the following test may be used:

要检查报头中接收字段的数量,可以使用以下测试:

header :count "ge" :comparator "i;ascii-numeric" ["received"] ["3"]

标题:计数“ge”:比较器“i;ascii数字”[“接收”][“3”]

This would return false. But

这将返回false。但是

header :count "ge" :comparator "i;ascii-numeric" ["received", "subject"] ["3"]

标题:计数“ge”:比较器“i;ascii数字”[“接收”,“主题”][“3”]

would return true.

将返回真值。

The test:

测试:

header :count "ge" :comparator "i;ascii-numeric" ["to", "cc"] ["3"]

标题:计数“ge”:比较器“i;ascii数字”[“to”,“cc”][“3”]

will always return false on an RFC 2822 compliant message [RFC2822], since a message can have at most one "to" field and at most one "cc" field. This test counts the number of fields, not the number of addresses.

将始终在符合RFC 2822的消息[RFC2822]上返回false,因为消息最多可以有一个“收件人”字段和一个“抄送”字段。此测试统计字段数,而不是地址数。

7 Extended Example

7扩展示例

require ["relational", "comparator-i;ascii-numeric"];

要求[“关系”、“比较器-i;ascii数字”];

   if header :value "lt" :comparator "i;ascii-numeric"
             ["x-priority"] ["3"]
   {
      fileinto "Priority";
   }
        
   if header :value "lt" :comparator "i;ascii-numeric"
             ["x-priority"] ["3"]
   {
      fileinto "Priority";
   }
        
   elseif address :count "gt" :comparator "i;ascii-numeric"
              ["to"] ["5"]
   {
      # everything with more than 5 recipients in the "to" field
      # is considered SPAM
      fileinto "SPAM";
   }
        
   elseif address :count "gt" :comparator "i;ascii-numeric"
              ["to"] ["5"]
   {
      # everything with more than 5 recipients in the "to" field
      # is considered SPAM
      fileinto "SPAM";
   }
        
   elseif address :value "gt" :all :comparator "i;ascii-casemap"
              ["from"] ["M"]
   {
      fileinto "From N-Z";
   } else {
      fileinto "From A-M";
   }
        
   elseif address :value "gt" :all :comparator "i;ascii-casemap"
              ["from"] ["M"]
   {
      fileinto "From N-Z";
   } else {
      fileinto "From A-M";
   }
        
   if allof ( address :count "eq" :comparator "i;ascii-numeric"
                      ["to", "cc"] ["1"] ,
              address :all :comparator "i;ascii-casemap"
                      ["to", "cc"] ["me@foo.example.com.invalid"]
   {
      fileinto "Only me";
   }
        
   if allof ( address :count "eq" :comparator "i;ascii-numeric"
                      ["to", "cc"] ["1"] ,
              address :all :comparator "i;ascii-casemap"
                      ["to", "cc"] ["me@foo.example.com.invalid"]
   {
      fileinto "Only me";
   }
        

8 IANA Considerations

8 IANA考虑因素

The following template specifies the IANA registration of the Sieve extension specified in this document:

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

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

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

Capability name: RELATIONAL Capability keyword: relational Capability arguments: N/A Standards Track/IESG-approved experimental RFC number: this RFC Person and email address to contact for further information: Wolfgang Segmuller IBM T.J. Watson Research Center 30 Saw Mill River Rd Hawthorne, NY 10532

能力名称:关系能力关键字:关系能力参数:N/A标准跟踪/IESG批准的实验RFC编号:此RFC人员和联系的电子邮件地址以获取更多信息:Wolfgang Segmuler IBM T.J.Watson研究中心30 Saw Mill River路霍桑,NY 10532

    Email: whs@watson.ibm.com
        
    Email: whs@watson.ibm.com
        

This information should be added to the list of sieve extensions given on http://www.iana.org/assignments/sieve-extensions.

该信息应添加到上给出的筛网扩展列表中http://www.iana.org/assignments/sieve-extensions.

9 References

9参考文献

9.1 Normative References
9.1 规范性引用文件

[SIEVE] Showalter, T., "Sieve: A Mail Filtering Language", RFC 3028, January 2001.

[SIEVE]Showalter,T.,“SIEVE:邮件过滤语言”,RFC30281001年1月。

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

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

[ABNF] Crocker, D., "Augmented BNF for Syntax Specifications: ABNF", RFC 2234, November 1997.

[ABNF]Crocker,D.,“语法规范的扩充BNF:ABNF”,RFC 2234,1997年11月。

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

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

9.2 Non-Normative References
9.2 非规范性引用文件

[ACAP] Newman, C. and J. G. Myers, "ACAP -- Application Configuration Access Protocol", RFC 2244, November 1997.

[ACAP]Newman,C.和J.G.Myers,“ACAP——应用程序配置访问协议”,RFC22441997年11月。

10 Author's Address

10作者地址

Wolfgang Segmuller IBM T.J. Watson Research Center 30 Saw Mill River Rd Hawthorne, NY 10532

沃尔夫冈·塞穆勒IBM T.J.沃森研究中心,纽约州霍桑市锯木勒河路30号,邮编10532

   EMail: whs@watson.ibm.com
        
   EMail: whs@watson.ibm.com
        

11 Full Copyright Statement

11完整版权声明

Copyright (C) The Internet Society (2002). All Rights Reserved.

版权所有(C)互联网协会(2002年)。版权所有。

This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to the Internet Society or other Internet organizations, except as needed for the purpose of developing Internet standards in which case the procedures for copyrights defined in the Internet Standards process must be followed, or as required to translate it into languages other than English.

本文件及其译本可复制并提供给他人,对其进行评论或解释或协助其实施的衍生作品可全部或部分编制、复制、出版和分发,不受任何限制,前提是上述版权声明和本段包含在所有此类副本和衍生作品中。但是,不得以任何方式修改本文件本身,例如删除版权通知或对互联网协会或其他互联网组织的引用,除非出于制定互联网标准的需要,在这种情况下,必须遵循互联网标准过程中定义的版权程序,或根据需要将其翻译成英语以外的其他语言。

The limited permissions granted above are perpetual and will not be revoked by the Internet Society or its successors or assigns.

上述授予的有限许可是永久性的,互联网协会或其继承人或受让人不会撤销。

This document and the information contained herein is provided on an "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIMS 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.

本文件和其中包含的信息是按“原样”提供的,互联网协会和互联网工程任务组否认所有明示或暗示的保证,包括但不限于任何保证,即使用本文中的信息不会侵犯任何权利,或对适销性或特定用途适用性的任何默示保证。

Acknowledgement

确认

Funding for the RFC Editor function is currently provided by the Internet Society.

RFC编辑功能的资金目前由互联网协会提供。