Network Working Group                                          T. Hansen
Request for Comments: 5703                             AT&T Laboratories
Category: Standards Track                                       C. Daboo
                                                              Apple Inc.
                                                            October 2009
        
Network Working Group                                          T. Hansen
Request for Comments: 5703                             AT&T Laboratories
Category: Standards Track                                       C. Daboo
                                                              Apple Inc.
                                                            October 2009
        

Sieve Email Filtering: MIME Part Tests, Iteration, Extraction, Replacement, and Enclosure

筛选电子邮件筛选:MIME部件测试、迭代、提取、替换和封装

Abstract

摘要

This document defines extensions to the Sieve email filtering language to permit analysis and manipulation of the MIME body parts of an email message.

本文档定义了对Sieve电子邮件过滤语言的扩展,以允许对电子邮件的MIME正文部分进行分析和操作。

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) 2009 IETF Trust and the persons identified as the document authors. All rights reserved.

版权所有(c)2009 IETF信托基金和确定为文件作者的人员。版权所有。

This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the BSD License.

本文件受BCP 78和IETF信托有关IETF文件的法律规定的约束(http://trustee.ietf.org/license-info)自本文件出版之日起生效。请仔细阅读这些文件,因为它们描述了您对本文件的权利和限制。从本文件中提取的代码组件必须包括《信托法律条款》第4.e节中所述的简化BSD许可文本,并且提供BSD许可中所述的代码组件时不提供任何担保。

This document may contain material from IETF Documents or IETF Contributions published or made publicly available before November 10, 2008. The person(s) controlling the copyright in some of this material may not have granted the IETF Trust the right to allow modifications of such material outside the IETF Standards Process. Without obtaining an adequate license from the person(s) controlling the copyright in such materials, this document may not be modified

本文件可能包含2008年11月10日之前发布或公开的IETF文件或IETF贡献中的材料。控制某些材料版权的人员可能未授予IETF信托允许在IETF标准流程之外修改此类材料的权利。未获得控制此类材料版权的人员的充分许可,不得修改本文件

outside the IETF Standards Process, and derivative works of it may not be created outside the IETF Standards Process, except to format it for publication as an RFC or to translate it into languages other than English.

在IETF标准过程之外,不得在IETF标准过程之外创建其衍生作品,除非将其格式化为RFC出版或将其翻译为英语以外的语言。

Table of Contents

目录

   1. Introduction ....................................................2
   2. Conventions Used in This Document ...............................3
   3. Sieve Loops: Actions "foreverypart" and "break" .................3
   4. Changes to Sieve Tests ..........................................4
      4.1. Test "header" ..............................................4
      4.2. Test "address" .............................................7
      4.3. Test "exists" ..............................................8
   5. Action "replace" ................................................8
   6. Action "enclose" ...............................................10
   7. Action "extracttext" ...........................................11
   8. Sieve Capability Strings .......................................11
   9. Examples .......................................................12
      9.1. Example 1 .................................................12
      9.2. Example 2 .................................................12
      9.3. Example 3 .................................................13
   10. Acknowledgements ..............................................13
   11. Security Considerations .......................................14
   12. IANA Considerations ...........................................14
      12.1. foreverypart capability ..................................15
      12.2. mime capability ..........................................15
      12.3. replace capability .......................................15
      12.4. enclose capability .......................................16
      12.5. extracttext capability ...................................16
   13. References ....................................................16
      13.1. Normative References .....................................16
      13.2. Informative References ...................................17
        
   1. Introduction ....................................................2
   2. Conventions Used in This Document ...............................3
   3. Sieve Loops: Actions "foreverypart" and "break" .................3
   4. Changes to Sieve Tests ..........................................4
      4.1. Test "header" ..............................................4
      4.2. Test "address" .............................................7
      4.3. Test "exists" ..............................................8
   5. Action "replace" ................................................8
   6. Action "enclose" ...............................................10
   7. Action "extracttext" ...........................................11
   8. Sieve Capability Strings .......................................11
   9. Examples .......................................................12
      9.1. Example 1 .................................................12
      9.2. Example 2 .................................................12
      9.3. Example 3 .................................................13
   10. Acknowledgements ..............................................13
   11. Security Considerations .......................................14
   12. IANA Considerations ...........................................14
      12.1. foreverypart capability ..................................15
      12.2. mime capability ..........................................15
      12.3. replace capability .......................................15
      12.4. enclose capability .......................................16
      12.5. extracttext capability ...................................16
   13. References ....................................................16
      13.1. Normative References .....................................16
      13.2. Informative References ...................................17
        
1. Introduction
1. 介绍

MIME messages ([RFC2045]) are often complex objects, consisting of many parts and sub-parts. This Sieve ([RFC5228]) extension defines mechanisms for performing tests on MIME body parts, looping through the MIME body parts, extracting information from a MIME body part, changing the contents of a MIME body part, and enclosing the entire message within a wrapper.

MIME消息([RFC2045])通常是复杂的对象,由许多部分和子部分组成。这个Sieve([RFC5228])扩展定义了对MIME正文部分执行测试、循环MIME正文部分、从MIME正文部分提取信息、更改MIME正文部分的内容以及将整个消息封装在包装器中的机制。

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

Conventions for notations are as in [RFC5228], Section 1.1.

符号惯例见[RFC5228]第1.1节。

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 [RFC2119].

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

3. Sieve Loops: Actions "foreverypart" and "break"
3. 筛环:动作“永远分”和“断开”

The base Sieve language has no looping mechanism. Given that messages may contain multiple parts, in order to support filters that apply to any and all parts, we introduce a new control command: "foreverypart", which is an iterator that walks though every MIME part of a message, including nested parts, depth first, and applies the commands in the specified block to each of them. The iterator will start with the first MIME part (as its current context) and will execute a command block (Sieve commands enclosed by {...}). Upon completion of this command block, the iterator advances to the next MIME part (as its current context) and executes the same command block again.

基本筛语言没有循环机制。鉴于消息可能包含多个部分,为了支持应用于任何和所有部分的过滤器,我们引入了一个新的控制命令:“foreverypart”,它是一个迭代器,遍历消息的每个MIME部分,包括嵌套部分,深度优先,并将指定块中的命令应用于每个部分。迭代器将从第一个MIME部分(作为其当前上下文)开始,并将执行一个命令块(用{…}括起来的筛选命令)。完成此命令块后,迭代器前进到下一个MIME部分(作为其当前上下文),并再次执行相同的命令块。

The iterator can be terminated prematurely by a new Sieve control command, "break".

迭代器可以通过新的筛选控制命令“break”提前终止。

Usage: foreverypart [":name" string] block

用法:foreverypart[“:name”string]块

   Usage:  break [":name" string];
        
   Usage:  break [":name" string];
        

"foreverypart" commands can be nested inside other "foreverypart" commands. When this occurs, the nested "foreverypart" iterates over the MIME parts contained within the MIME part currently being targeted by the nearest enclosing "foreverypart" command. (That is, the inner loop only operates on children of the bodypart currently accessed by the outer loop.) If that MIME part is a terminal MIME part (i.e., does not contain other MIME parts), then the nested "foreverypart" loop is simply ignored.

“foreverypart”命令可以嵌套在其他“foreverypart”命令中。出现这种情况时,嵌套的“foreverypart”将迭代最近的封闭“foreverypart”命令所针对的MIME部分中包含的MIME部分。(也就是说,内部循环仅对当前由外部循环访问的bodypart的子项进行操作。)如果该MIME部分是终端MIME部分(即,不包含其他MIME部分),则只会忽略嵌套的“foreverypart”循环。

Sieve implementations MAY limit the number of nested loops that occur within one another; however, they MUST support at least one nested loop inside another loop.

筛子实现可能会限制相互之间发生的嵌套循环的数量;但是,它们必须在另一个循环中至少支持一个嵌套循环。

If a name is given to a "break" command, it terminates the closest enclosing loop with the identical matching name. (If a nested "foreverypart" name is the same as a "foreverypart" name in an outer level, the outer level name is hidden.) It is an error if there is no enclosing loop with that name.

如果为“break”命令指定了一个名称,则该命令将以相同的匹配名称终止最近的封闭循环。(如果嵌套的“foreverypart”名称与外部级别中的“foreverypart”名称相同,则外部级别名称将隐藏。)如果没有具有该名称的封闭循环,则为错误。

If no name is given in a "break" command (i.e., the ":name" parameter is omitted), the break command terminates the closest enclosing loop.

如果“break”命令中没有给出名称(即:name”参数被省略),break命令将终止最近的封闭循环。

4. Changes to Sieve Tests
4. 筛分试验的变化

This specification extends the base Sieve "header", "address", and "exists" tests to support targeting those tests at a specific MIME part or at all MIME parts in the enclosing scope.

本规范扩展了基本筛选“header”、“address”和“exists”测试,以支持针对特定MIME部分或封闭范围内所有MIME部分的测试。

4.1. Test "header"
4.1. 测试“标题”

The "header" test is extended with the addition of new ":mime" and ":anychild" tagged arguments and their associated options.

“header”测试通过添加新的“:mime”和“:anychild”标记参数及其相关选项进行扩展。

   Usage:  header [":mime"] [":anychild"] [MIMEOPTS]
      [COMPARATOR] [MATCH-TYPE]
      <header-names: string-list> <key-list: string-list>
        
   Usage:  header [":mime"] [":anychild"] [MIMEOPTS]
      [COMPARATOR] [MATCH-TYPE]
      <header-names: string-list> <key-list: string-list>
        

The definition of [MIMEOPTS] is:

[MIMEOPTS]的定义是:

   Syntax:  ":type" / ":subtype" / ":contenttype" /
      ":param" <param-list: string-list>
        
   Syntax:  ":type" / ":subtype" / ":contenttype" /
      ":param" <param-list: string-list>
        

When the ":mime" tagged argument is present in the "header" test, it will parse the MIME header lines in the message so that tests can be performed on specific elements. The ":anychild" tagged argument may only appear when the ":mime" tagged argument is present, and only modifies the semantics of the ":mime" tagged argument. That is, presence of the ":anychild" in absence of ":mime" is an error.

当“:mime”标记的参数出现在“header”测试中时,它将解析消息中的mime头行,以便可以对特定元素执行测试。“:anychild”标记参数只能在“:mime”标记参数存在时出现,并且只修改“:mime”标记参数的语义。也就是说,在缺少“:mime”的情况下出现“:anychild”是一个错误。

When used outside the context of a "foreverypart" iterator, and without an ":anychild" tagged argument, the "header" test will examine only the outer top-level [RFC5322] headers of the message.

当在“foreverypart”迭代器的上下文之外使用并且没有“:anychild”标记参数时,“header”测试将只检查消息的外部顶级[RFC5322]头。

When used inside the context of a "foreverypart" iterator, and without an ":anychild" tagged argument, the "header" test will examine the headers associated with the current MIME part context from the loop.

在“foreverypart”迭代器的上下文中使用时,如果没有“:anychild”标记的参数,“header”测试将从循环中检查与当前MIME部件上下文关联的头。

When used outside the context of a "foreverypart" iterator, and with an ":anychild" tagged argument, the "header" test will examine all MIME body parts and return true if any of them satisfies the test.

当在“foreverypart”迭代器的上下文之外使用时,并且带有“:anychild”标记的参数,“header”测试将检查所有MIME主体部分,如果其中任何部分满足测试,则返回true。

When used inside the context of a "foreverypart" iterator, and with an ":anychild" tagged argument, the "header" test will examine the current MIME part context and all its nested MIME body parts, returning true if any of them satisfies the test.

当在“foreverypart”迭代器的上下文中使用时,并且带有“:anychild”标记的参数,“header”测试将检查当前MIME部件上下文及其所有嵌套的MIME正文部件,如果其中任何部件满足测试,则返回true。

The "header" test with the ":mime" tagged argument can test various aspects of certain structured MIME headers. Implementations SHOULD support desegmentation, decoding, and charset translation of parameter values encoded according to [RFC2231] as part of this test. Additionally, [RFC2047] describes a process whereby [RFC5322] headers can be encoded in various ways. That encoding is not strictly allowed in MIME parameters; however, in practice, it has been used in many email implementations. So, Sieve implementations MAY decode [RFC2047]-encoded words in parameter values as part of this test.

带有“:mime”标记参数的“header”测试可以测试某些结构化mime头的各个方面。作为本测试的一部分,实现应支持对根据[RFC2231]编码的参数值进行分段、解码和字符集转换。此外,[RFC2047]描述了一个过程,[RFC5322]头可以通过各种方式编码。MIME参数中不严格允许这种编码;然而,在实践中,它已在许多电子邮件实现中使用。因此,作为该测试的一部分,Sieve实现可以解码参数值中的[rfc247]编码字。

These options are available:

这些选项可用:

:type for a "Content-Type" MIME header field, parses and tests the value of the MIME type specified in the header; for a "Content-Disposition" MIME header field, parses and tests the value of the disposition specified in the header; for other MIME headers, uses a blank string for the test.

:键入“Content type”MIME标头字段,解析并测试标头中指定的MIME类型的值;对于“Content Disposition”MIME头字段,解析并测试头中指定的处置值;对于其他MIME头,使用空字符串进行测试。

:subtype for a "Content-Type" MIME header field, parses and tests the value of the MIME subtype specified in the header; for a "Content-Disposition" MIME header field, uses a blank string for the test; for other MIME headers, uses a blank string for the test.

:用于“内容类型”MIME头字段的子类型,解析并测试头中指定的MIME子类型的值;对于“Content Disposition”MIME头字段,使用空白字符串进行测试;对于其他MIME头,使用空字符串进行测试。

:contenttype for a "Content-Type" MIME header field, parses and tests the combined value of the MIME type and subtype specified in the header; for a "Content-Disposition" MIME header field, behaves the same as the ":type" option; for other MIME headers, uses a blank string for the test.

:contenttype用于“Content Type”MIME头字段,解析并测试头中指定的MIME类型和子类型的组合值;对于“Content Disposition”MIME头字段,其行为与“:type”选项相同;对于其他MIME头,使用空字符串进行测试。

:param parses the header looking for MIME parameters in the header. The supplied string-list lists the names of any parameters to be tested. If any one named parameter value matches any of the test string values, the test will return true.

:param解析标头,在标头中查找MIME参数。提供的字符串列表列出了要测试的任何参数的名称。如果任何一个命名参数值与任何测试字符串值匹配,测试将返回true。

When the ":count" option from [RFC5231] is used, the following applies:

当使用[RFC5231]中的“:count”选项时,以下情况适用:

a. for ":type", ":subtype", or ":contenttype", return a count of the number of headers that parsed successfully

a. 对于“:type”、“:subtype”或“:contenttype”,返回成功解析的头数的计数

b. for ":param", return a count of the number of parameters with the given name that were found

b. 对于“:param”,返回找到的具有给定名称的参数数量的计数

Example:

例子:

require ["mime", "fileinto"];

要求[“mime”,“fileinto”];

   if header :mime :type "Content-Type" "image"
   {
       fileinto "INBOX.images";
   }
        
   if header :mime :type "Content-Type" "image"
   {
       fileinto "INBOX.images";
   }
        

In this example, any message that contains a MIME image type part at the top-level is saved to the mailbox "INBOX.images".

在本例中,任何包含顶级MIME图像类型部分的邮件都会保存到邮箱“INBOX.images”中。

Example:

例子:

require ["mime", "fileinto"];

要求[“mime”,“fileinto”];

   if header :mime :anychild :contenttype
             "Content-Type" "text/html"
   {
       fileinto "INBOX.html";
   }
        
   if header :mime :anychild :contenttype
             "Content-Type" "text/html"
   {
       fileinto "INBOX.html";
   }
        

In this example, any message that contains any MIME part with a content-type of "text/html" is saved to the mailbox "INBOX.html".

在本例中,任何包含内容类型为“text/html”的MIME部分的邮件都会保存到邮箱“INBOX.html”中。

Example:

例子:

require ["mime", "foreverypart", "fileinto"];

要求[“mime”、“永久部分”、“文件导入”];

   foreverypart
   {
       if allof (
         header :mime :param "filename" :contains
            "Content-Disposition" "important",
         header :mime :subtype "Content-Type" "pdf",
         size :over "100K")
       {
           fileinto "INBOX.important";
           break;
       }
   }
        
   foreverypart
   {
       if allof (
         header :mime :param "filename" :contains
            "Content-Disposition" "important",
         header :mime :subtype "Content-Type" "pdf",
         size :over "100K")
       {
           fileinto "INBOX.important";
           break;
       }
   }
        

In this example, any message that contains a MIME part that has a content-disposition with a filename parameter containing the text "important", has a content-subtype of "pdf" and is bigger than 100 Kb is saved to the mailbox "INBOX.important".

在本例中,任何包含MIME部分的邮件都会保存到邮箱“INBOX.important”中,该MIME部分的内容配置文件名参数包含文本“important”,内容子类型为“pdf”且大于100KB。

4.2. Test "address"
4.2. 测试“地址”

The "address" test is extended with the addition of new ":mime" and ":anychild" tagged arguments and their associated options.

“address”测试通过添加新的“:mime”和“:anychild”标记的参数及其相关选项进行扩展。

   Usage:  address [":mime"] [":anychild"] [COMPARATOR]
      [ADDRESS-PART] [MATCH-TYPE]
      <header-list: string-list> <key-list: string-list>
        
   Usage:  address [":mime"] [":anychild"] [COMPARATOR]
      [ADDRESS-PART] [MATCH-TYPE]
      <header-list: string-list> <key-list: string-list>
        

When the ":mime" tagged argument is present in the "address" test, it will parse the MIME header lines as if they were standard address header lines in a message so that tests can be performed on specific elements.

当“:mime”标记的参数出现在“address”测试中时,它将解析mime头行,就像它们是消息中的标准地址头行一样,以便可以对特定元素执行测试。

The behavior of the ":anychild" tagged argument and the interaction with the "foreverypart" iterator is the same as for the extended "header" test in Section 4.1.

“:anychild”标记参数的行为以及与“foreverypart”迭代器的交互与第4.1节中扩展的“header”测试的行为相同。

That is,

就是,

the use of "address" when both the ":mime" and ":anychild" tagged arguments are omitted is the test defined in [RFC5228], i.e., it will *only* operate on top-level header fields, whether or not it is inside "foreverypart".

当“:mime”和“:anychild”标记的参数都被省略时,“address”的使用是[RFC5228]中定义的测试,即它将*仅*操作顶级头字段,无论它是否在“foreverypart”内。

the use of "address" with ":mime" and no ":anychild" operates on the current MIME part only (or on the top-level header fields, if outside "foreverypart").

“address”与“:mime”和“no”:anychild”一起使用时,仅对当前mime部分(或顶级头字段,如果在“foreverypart”之外)进行操作。

the use of "address" with ":mime" and ":anychild" operates on the current MIME part and all of its descendants.

将“地址”与“:mime”和“:anychild”一起使用可对当前mime部分及其所有子代进行操作。

Example:

例子:

require ["mime", "fileinto"];

要求[“mime”,“fileinto”];

   if address :mime :is :all "content-from" "tim@example.com"
   {
       fileinto "INBOX.part-from-tim";
   }
        
   if address :mime :is :all "content-from" "tim@example.com"
   {
       fileinto "INBOX.part-from-tim";
   }
        

In this example, any message that contains a MIME Content-From header at the top-level matching the text "tim@example.com" is saved to the mailbox "INBOX.part-from-tim".

在本例中,任何包含MIME内容的邮件,其标题位于与文本匹配的顶层”tim@example.com已保存到邮箱“INBOX.part from tim”。

4.3. Test "exists"
4.3. 测试“存在”

The "exists" test is extended with the addition of the new ":mime" and ":anychild" tagged arguments and their associated options.

“exists”测试通过添加新的“:mime”和“:anychild”标记参数及其相关选项进行扩展。

   Usage:  exists [":mime"] [":anychild"] <header-names: string-list>
        
   Usage:  exists [":mime"] [":anychild"] <header-names: string-list>
        

When the ":mime" tagged argument is present in the "exists" test, the test is extended to check for the existence of MIME headers in MIME parts.

当“:mime”标记的参数出现在“exists”测试中时,该测试将被扩展以检查mime部件中是否存在mime头。

The behavior of the ":anychild" tagged argument and the interaction with the "foreverypart" iterator is the same as for the extended "header" test Section 4.1.

“:anychild”标记参数的行为以及与“foreverypart”迭代器的交互与扩展“header”测试第4.1节的行为相同。

That is,

就是,

the use of "exists" when both the ":mime" and ":anychild" tagged arguments are omitted is the test defined in [RFC5228], i.e., it will *only* operate on top-level header fields, whether or not it is inside "foreverypart".

当“:mime”和“:anychild”标记的参数都被省略时,“exists”的使用是[RFC5228]中定义的测试,即它将*仅*操作顶级头字段,无论它是否在“foreverypart”中。

the use of "exists" with ":mime" and no ":anychild" operates on the current MIME part only (or on the top-level header fields, if outside "foreverypart").

“exists”与“:mime”和“no”:anychild”一起使用时,仅对当前mime部分(或顶级头字段,如果在“foreverypart”之外)进行操作。

the use of "exists" with ":mime" and ":anychild" operates on the current MIME part and all of its descendants.

与“:mime”和“:anychild”一起使用“exists”对当前mime部分及其所有子代进行操作。

Example:

例子:

require ["mime", "fileinto"];

要求[“mime”,“fileinto”];

   if exists :mime :anychild "content-md5"
   {
       fileinto "INBOX.md5";
   }
        
   if exists :mime :anychild "content-md5"
   {
       fileinto "INBOX.md5";
   }
        

In this example, any message that contains a MIME Content-MD5 header in any MIME part is saved to the mailbox "INBOX.md5".

在本例中,任何MIME部分中包含MIME Content-MD5头的邮件都会保存到邮箱“INBOX.MD5”中。

5. Action "replace"
5. 行动“替换”
   Usage:  replace [":mime"] [":subject" string] [":from" string]
      <replacement: string>
        
   Usage:  replace [":mime"] [":subject" string] [":from" string]
      <replacement: string>
        

The "replace" command is defined to allow a MIME part to be replaced with the text supplied in the command.

“replace”命令定义为允许用命令中提供的文本替换MIME部分。

When used in the context of a "foreverypart" iterator, the MIME part to be replaced is the "current" MIME part. If the current MIME context is a multipart MIME part, the entire multipart MIME part is replaced, which would alter the MIME structure of the message by eliminating all of the children of the multipart part. (Replacing a non-multipart MIME part within a "foreverypart" loop context does not alter the overall message structure.) If the MIME structure is altered, the change takes effect immediately: the "foreverypart" iterator that is executing does not go into the no-longer existing body parts, and subsequent "foreverypart" iterators would use the new message structure.

在“foreverypart”迭代器的上下文中使用时,要替换的MIME部分是“当前”MIME部分。如果当前MIME上下文是一个多部分MIME部分,则将替换整个多部分MIME部分,这将通过删除多部分部分的所有子项来改变消息的MIME结构。(在“foreverypart”循环上下文中替换非多部分MIME部分不会改变整个消息结构。)如果MIME结构被更改,更改将立即生效:正在执行的“foreverypart”迭代器不会进入不再存在的正文部分,以及后续的“foreverypart”迭代器将使用新的消息结构。

When used outside the context of a "foreverypart" loop, the MIME part to be replaced is the entire message.

当在“foreverypart”循环的上下文之外使用时,要替换的MIME部分是整个消息。

If the ":mime" parameter is not specified, the replacement string is a text/plain part in UTF-8 [RFC3629].

如果未指定“:mime”参数,则替换字符串是UTF-8[RFC3629]中的文本/普通部分。

If the ":mime" parameter is specified, then the replacement string is, in fact, a MIME entity as defined in [RFC2045], Section 2.4, including both MIME headers and content.

如果指定了“:mime”参数,那么替换字符串实际上是[RFC2045]第2.4节中定义的mime实体,包括mime头和内容。

If the entire message is being replaced, the optional ":subject" parameter specifies a subject line to attach to the message that is generated. UTF-8 characters can be used in the string argument; implementations MUST convert the string to [RFC2047]-encoded words if and only if non-ASCII characters are present. If the ":subject" parameter is used, implementations MUST preserve any previous Subject header as an Original-Subject header. Implementations MUST preserve all other header fields from the original message with the exception of those relating to the MIME structure that is being replaced.

如果要替换整个消息,则可选的“:subject”参数指定要附加到生成的消息的主题行。字符串参数中可以使用UTF-8字符;当且仅当存在非ASCII字符时,实现必须将字符串转换为[RFC2047]编码字。如果使用“:subject”参数,则实现必须将以前的任何主题标题保留为原始主题标题。实现必须保留原始消息中的所有其他头字段,与被替换的MIME结构相关的头字段除外。

If the entire message is being replaced, as an indication that the message is no longer as created by the original author of the message, the optional ":from" parameter may be used to specify an alternate address to use in the From field of the message that is generated. The string must specify a valid [RFC5322] mailbox-list. Implementations SHOULD check the syntax and generate an error when a syntactically invalid ":from" parameter is specified. Implementations MAY also impose restrictions on what addresses can be specified in a ":from" parameter; it is suggested that values that fail such a validity check simply be ignored rather than causing the "replace" action to fail. If the From header is changed, implementations MUST preserve the previous From header as an Original-From header.

如果要替换整个消息,作为消息不再由消息的原始作者创建的指示,可选“:from”参数可用于指定要在生成的消息的from字段中使用的备用地址。字符串必须指定有效的[RFC5322]邮箱列表。当指定语法无效的“:from”参数时,实现应该检查语法并生成错误。实现还可能对在“:from”参数中指定的地址施加限制;建议忽略未通过有效性检查的值,而不是导致“替换”操作失败。如果更改了From标头,则实现必须将以前的From标头保留为原始From标头。

Implementations that support the "editheader" extension [RFC5293] MUST ensure that any Original-Subject or Original-From headers added by the system cannot be modified or removed. Implementations MAY prevent the addition of Original-Subject and Orignal-From headers via the "editheader" extension.

支持“editheader”扩展[RFC5293]的实现必须确保不能修改或删除系统添加的任何原始主题或原始标题。实现可能会阻止通过“editheader”扩展添加标题中的原始主题和原始名称。

If ":mime" is specified and either ":subject" or ":from" is specified, the ":subject:" or ":from" parameter MUST be ignored. This SHOULD be flagged as a compilation error.

如果指定了“:mime”并且指定了“:subject”或“:from”,则必须忽略“:subject:”或“:from”参数。这应标记为编译错误。

6. Action "enclose"
6. 行动“附上”
   Usage:  enclose <:subject string> <:headers string-list> string
        
   Usage:  enclose <:subject string> <:headers string-list> string
        

A new Sieve action command is defined to allow an entire message to be enclosed as an attachment to a new message. After enclosure, subsequent actions affecting the message header or content, as well as tests operating on the MIME structure or accessing MIME header fields, use the newly created message instead of the original message; this means that any use of a "replace" action or other similar actions should be executed before the "enclose" action.

定义了一个新的Sieve操作命令,以允许将整个消息作为新消息的附件进行封装。封闭后,影响消息头或内容的后续操作,以及在MIME结构上操作或访问MIME头字段的测试,使用新创建的消息而不是原始消息;这意味着任何“替换”操作或其他类似操作的使用都应该在“封闭”操作之前执行。

If multiple "enclose" actions are executed by a script, the message is enclosed multiple times. (If a Sieve script desires to choose between different enclosures, or wants to delay the enclosure to the end of the script, it can use variables with appropriate tests [RFC5229].)

如果一个脚本执行多个“封闭”操作,则消息会被封闭多次。(如果筛选脚本希望在不同的存储模块之间进行选择,或者希望将存储模块延迟到脚本末尾,则可以使用带有适当测试的变量[RFC5229]。)

This action does not affect messages that are forwarded via a "redirect" action.

此操作不影响通过“重定向”操作转发的消息。

Specifically, the original message becomes a multipart/mixed message with two parts: a text/plain portion with the string argument as its body, and a message/rfc822 portion with the original message enclosed. The Content-Type: header field becomes multipart/mixed. The optional Subject: header is specified by the ":subject" argument; if not present, the subject will be taken from the enclosed message. Any headers specified by ":headers" are copied from the old message into the new message. If not specified by ":headers", Date: and From: headers should be synthesized to reflect the current date and the user running the Sieve action.

具体地说,原始消息将成为包含两部分的多部分/混合消息:文本/普通部分(以字符串参数为主体)和包含原始消息的消息/rfc822部分。内容类型:标题字段变为多部分/混合。可选的Subject:header由“:Subject”参数指定;如果不存在,主题将取自随附的信息。“:headers”指定的任何头都会从旧邮件复制到新邮件中。如果未由“:headers”指定,则应合成日期和发件人:标题,以反映当前日期和运行筛选操作的用户。

7. Action "extracttext"
7. “提取文本”行动
   Usage:  extracttext [MODIFIER] [":first" number] <varname: string>
        
   Usage:  extracttext [MODIFIER] [":first" number] <varname: string>
        

The "extracttext" action may be used within the context of a "foreverypart" loop and is used to store text into a variable as defined by [RFC5229]. Servers MUST support transcoding of any textual body part into UTF-8 for use with this action. This requires decoding any transfer encoding as well as transcoding from the indicated character set into UTF-8. It stores at most ":first" characters of the transcoded content of the current MIME body part in the variable identified by varname. If the ":first" parameter is not present, the whole content of the current MIME body part is stored. In either case, the actually stored data MAY be truncated to conform to implementation specific limit on variable length and/or on MIME body part length. If the transfer encoding or character set is unrecognized by the implementation or recognized but invalid, an empty string will result.

“extracttext”操作可在“foreverypart”循环的上下文中使用,并用于将文本存储到[RFC5229]定义的变量中。服务器必须支持将任何文本正文部分转换为UTF-8以用于此操作。这需要对任何传输编码进行解码,并将指示的字符集转换为UTF-8。它最多在varname标识的变量中存储当前MIME主体部分的转码内容的“:first”字符。如果“:first”参数不存在,则存储当前MIME主体部分的全部内容。在这两种情况下,实际存储的数据可能会被截断,以符合变量长度和/或MIME正文部分长度的特定于实现的限制。如果传输编码或字符集未被实现识别,或已识别但无效,则将产生空字符串。

If "extracttext" is used outside the context of a "foreverypart" loop, the action will set the variable identified by varname to the empty string. This SHOULD be flagged as a compilation error.

如果在“foreverypart”循环的上下文之外使用“extracttext”,则该操作将把varname标识的变量设置为空字符串。这应标记为编译错误。

Modifiers are applied on the extracted text before it is stored in the variable.

在提取的文本存储在变量中之前,会对其应用修改器。

8. Sieve Capability Strings
8. 筛分能力串

A Sieve implementation that defines the "foreverypart" and "break" actions will advertise the capability string "foreverypart".

定义“foreverypart”和“break”操作的筛选实现将公布功能字符串“foreverypart”。

A Sieve implementation that defines the ":mime" and ":anychild" tagged arguments to the "header", "address", and "exists" commands will advertise the capability string "mime".

定义“:mime”和“:anychild”标记参数到“header”、“address”和“exists”命令的筛实现将公布功能字符串“mime”。

A Sieve implementation that defines the "replace" action will advertise the capability string "replace".

定义“replace”操作的Sieve实现将公布功能字符串“replace”。

A Sieve implementation that defines the "enclose" action will advertise the capability string "enclose".

定义“封闭”操作的筛选实现将公布功能字符串“封闭”。

A Sieve implementation that defines the "extracttext" action will advertise the capability string "extracttext". Note that to be useful, the "extracttext" action also requires the "variables" [RFC5229] and "foreverypart" capabilities.

定义“extracttext”操作的筛实现将公布功能字符串“extracttext”。请注意,“extracttext”操作还需要“variables”[RFC5229]和“foreverypart”功能才有用。

9. Examples
9. 例子
9.1. Example 1
9.1. 例1

Consider a Sieve script to replace some of the Windows executable attachments in a message. (The actual list of executable types and extensions is considerably longer and constantly changing. The tests shown here are an example only.) Such a script might look like this:

考虑一个筛选器脚本来替换消息中的一些Windows可执行附件。(可执行类型和扩展的实际列表相当长且不断变化。此处显示的测试仅为示例。)这样的脚本可能如下所示:

   require [ "foreverypart", "mime", "replace" ];
   foreverypart
   {
     if anyof (
            header :mime :contenttype :is
              "Content-Type" "application/exe",
            header :mime :param "filename"
              :matches ["Content-Type", "Content-Disposition"] "*.com" )
     {
       replace "Executable attachment removed by user filter";
     }
   }
        
   require [ "foreverypart", "mime", "replace" ];
   foreverypart
   {
     if anyof (
            header :mime :contenttype :is
              "Content-Type" "application/exe",
            header :mime :param "filename"
              :matches ["Content-Type", "Content-Disposition"] "*.com" )
     {
       replace "Executable attachment removed by user filter";
     }
   }
        
9.2. Example 2
9.2. 例2

Consider a Sieve script to warn the user about some of the executable attachment types. (The actual list of executable types and extensions is considerably longer and constantly changing. The tests shown here are an example only.) Such a script might look like this:

考虑一个筛选器脚本来警告用户一些可执行的附件类型。(可执行类型和扩展的实际列表相当长且不断变化。此处显示的测试仅为示例。)这样的脚本可能如下所示:

require [ "foreverypart", "mime", "enclose" ];

要求[“永久部分”、“默剧”、“附上”];

   foreverypart
   {
     if header :mime :param "filename"
        :matches ["Content-Type", "Content-Disposition"]
          ["*.com", "*.exe", "*.vbs", "*.scr",
           "*.pif", "*.hta", "*.bat", "*.zip" ]
     {
       # these attachment types are executable
       enclose :subject "Warning" :text
   WARNING! The enclosed message contains executable attachments.
   These attachment types may contain a computer virus program
   that can infect your computer and potentially damage your data.
        
   foreverypart
   {
     if header :mime :param "filename"
        :matches ["Content-Type", "Content-Disposition"]
          ["*.com", "*.exe", "*.vbs", "*.scr",
           "*.pif", "*.hta", "*.bat", "*.zip" ]
     {
       # these attachment types are executable
       enclose :subject "Warning" :text
   WARNING! The enclosed message contains executable attachments.
   These attachment types may contain a computer virus program
   that can infect your computer and potentially damage your data.
        

Before clicking on these message attachments, you should verify with the sender that this message was sent by them and not a computer virus.

在单击这些邮件附件之前,您应该与发件人确认此邮件是由他们发送的,而不是计算机病毒。

   .
   ;
       break;
     }
   }
        
   .
   ;
       break;
     }
   }
        
9.3. Example 3
9.3. 例3

A Sieve script to extract subject and text out of messages from the boss might look like this:

从boss消息中提取主题和文本的筛选脚本可能如下所示:

require ["mime", "variables", "extracttext"];

要求[“mime”、“变量”、“提取文本”];

   if header :contains "from" "boss@example.org"
   {
     # :matches is used to get the value of the Subject header
     if header :matches "Subject" "*"
     {
       set "subject" "${1}";
     }
        
   if header :contains "from" "boss@example.org"
   {
     # :matches is used to get the value of the Subject header
     if header :matches "Subject" "*"
     {
       set "subject" "${1}";
     }
        
     # extract the first 100 characters of the first text/* part
     foreverypart
     {
       if header :mime :type :is "Content-Type" "text"
       {
         extracttext :first 100 "msgcontent";
         break;
       }
     }
        
     # extract the first 100 characters of the first text/* part
     foreverypart
     {
       if header :mime :type :is "Content-Type" "text"
       {
         extracttext :first 100 "msgcontent";
         break;
       }
     }
        
     # if it's not a 'for your information' message
     if not header :contains "subject" "FYI:"
     {
       # do something using ${subject} and ${msgcontent}
       # such as sending a notification using a
       # notification extension
     }
   }
        
     # if it's not a 'for your information' message
     if not header :contains "subject" "FYI:"
     {
       # do something using ${subject} and ${msgcontent}
       # such as sending a notification using a
       # notification extension
     }
   }
        
10. Acknowledgements
10. 致谢

Comments from members of the MTA Filters Working Group, in particular Ned Freed, Kjetil Torgrim Homme, Mark Mallett, Alexey Melnikov, Aaron Stone, and Nigel Swinson are gratefully acknowledged.

感谢MTA过滤器工作组成员的评论,特别是Ned Freed、Kjetil Torgrim Homme、Mark Mallett、Alexey Melnikov、Aaron Stone和Nigel Swinson。

11. Security Considerations
11. 安全考虑

The "enclose" action creates an entirely new message, as compared to just redirecting or forwarding the existing message. Therefore, any site policies applicable to message submission should be enforced.

与仅仅重定向或转发现有消息相比,“封闭”操作创建了一个全新的消息。因此,应强制执行适用于邮件提交的任何站点策略。

The looping specification specified here provides easier access to information about the message contents, which may also be achieved through other sieve tests. This is not believed to raise any additional security issues beyond those for the Sieve "envelope" and "body" [RFC5173] tests.

这里指定的循环规范提供了对消息内容信息的更容易访问,这也可以通过其他筛选测试实现。除了筛“信封”和“主体”[RFC5173]测试之外,这不会引发任何额外的安全问题。

Any change in message content may interfere with digital signature mechanisms that include that content in the signed material. In particular, using "replace" makes direct changes to the body content and will affect the body hash included in Domain Keys Identified Mail (DKIM) signatures [RFC4871], or the message signature used for Secure MIME (S/MIME) [RFC3851], Pretty Good Privacy (PGP) [RFC1991] or OpenPGP [RFC4880].

消息内容的任何更改都可能会干扰在已签名材料中包含该内容的数字签名机制。特别是,使用“替换”可直接更改正文内容,并将影响域密钥标识邮件(DKIM)签名[RFC4871]中包含的正文哈希,或用于安全MIME(S/MIME)[RFC3851]、相当好的隐私(PGP)[RFC1991]或OpenPGP[RFC4880]的消息签名。

It is not possible to examine the MIME structure of decrypted content in a multipart/encrypted MIME part.

无法在多部分/加密MIME部分中检查解密内容的MIME结构。

When "enclose" is used on a message containing a multipart/signed MIME part, the Sieve implementation MUST ensure that the original message is copied octet-for-octet to maintain the validity of the digital signature.

当在包含多部分/签名MIME部分的消息上使用“include”时,SIVE实现必须确保将原始消息复制为八位字节,以保持数字签名的有效性。

The system MUST be sized and restricted in such a manner that even malicious use of MIME part matching does not deny service to other users of the host system.

系统的大小和限制必须确保即使恶意使用MIME部件匹配也不会拒绝主机系统的其他用户的服务。

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

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

12. IANA Considerations
12. IANA考虑

The Original-Subject and Original-From headers have been registered in the Permanent Message Header Fields registry.

原始主题和原始发件人标题已在永久邮件标题字段注册表中注册。

The following templates specify the IANA registrations of the Sieve extensions specified in this document. This information has been added to the IANA registry of Sieve Extensions (currently found at http://www.iana.org).

以下模板规定了本文件中规定的筛网扩展的IANA注册。此信息已添加到IANA筛扩展注册表(目前可在http://www.iana.org).

12.1. foreverypart capability
12.1. 永久性能力

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

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

Capability name: foreverypart Description: adds the "foreverypart" and "break" actions for iterating through MIME parts of a message.

功能名称:foreverypart描述:添加“foreverypart”和“break”操作,用于迭代消息的MIME部分。

RFC number: RFC 5703 Contact address: The Sieve discussion list <ietf-mta-filters@imc.org>.

RFC编号:RFC 5703联系地址:筛讨论列表<ietf mta-filters@imc.org>.

12.2. mime capability
12.2. mime功能

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

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

Capability name: mime Description: adds the ":mime" and ":anychild" tagged arguments to the "header", "address", and "exists" tests. Adds the ":type", ":subtype", ":contenttype", and ":param" options when ":mime" is used with the "header" test.

功能名称:mime描述:将“:mime”和“:anychild”标记的参数添加到“header”、“address”和“exists”测试中。当“:mime”用于“header”测试时,添加“:type”、“:subtype”、“:contenttype”和“:param”选项。

RFC number: RFC 5703 Contact address: The Sieve discussion list <ietf-mta-filters@imc.org>.

RFC编号:RFC 5703联系地址:筛讨论列表<ietf mta-filters@imc.org>.

12.3. replace capability
12.3. 替换能力

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

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

Capability name: replace Description: adds the "replace" action for replacing a MIME body part of a message.

功能名称:替换描述:添加“替换”操作以替换消息的MIME正文部分。

RFC number: RFC 5703 Contact address: The Sieve discussion list <ietf-mta-filters@imc.org>.

RFC编号:RFC 5703联系地址:筛讨论列表<ietf mta-filters@imc.org>.

12.4. enclose capability
12.4. 封闭能力

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

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

Capability name: enclose Description: adds the "enclose" action for enclosing a message with a wrapper.

功能名称:include Description:添加“include”操作,用于用包装器封装消息。

RFC number: RFC 5703 Contact address: The Sieve discussion list <ietf-mta-filters@imc.org>.

RFC编号:RFC 5703联系地址:筛讨论列表<ietf mta-filters@imc.org>.

12.5. extracttext capability
12.5. 提取文本功能

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

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

Capability name: extracttext Description: adds the "extracttext" action for extracting text from a

功能名称:extracttext描述:添加“extracttext”操作以从

MIME body part.

模仿身体部位。

RFC number: RFC 5703 Contact address: The Sieve discussion list <ietf-mta-filters@imc.org>.

RFC编号:RFC 5703联系地址:筛讨论列表<ietf mta-filters@imc.org>.

13. References
13. 工具书类
13.1. Normative References
13.1. 规范性引用文件

[RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies", RFC 2045, November 1996.

[RFC2045]Freed,N.和N.Borenstein,“多用途Internet邮件扩展(MIME)第一部分:Internet邮件正文格式”,RFC 20451996年11月。

[RFC2047] Moore, K., "MIME (Multipurpose Internet Mail Extensions) Part Three: Message Header Extensions for Non-ASCII Text", RFC 2047, November 1996.

[RFC2047]Moore,K.,“MIME(多用途互联网邮件扩展)第三部分:非ASCII文本的消息头扩展”,RFC 2047,1996年11月。

[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月。

[RFC2231] Freed, N. and K. Moore, "MIME Parameter Value and Encoded Word Extensions: Character Sets, Languages, and Continuations", RFC 2231, November 1997.

[RFC2231]Freed,N.和K.Moore,“MIME参数值和编码字扩展:字符集、语言和连续体”,RFC 22311997年11月。

[RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 10646", STD 63, RFC 3629, November 2003.

[RFC3629]Yergeau,F.,“UTF-8,ISO 10646的转换格式”,STD 63,RFC 3629,2003年11月。

[RFC5173] Degener, J. and P. Guenther, "Sieve Email Filtering: Body Extension", RFC 5173, April 2008.

[RFC5173]Degener,J.和P.Guenther,“筛选电子邮件过滤:正文扩展”,RFC 5173,2008年4月。

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

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

[RFC5229] Homme, K., "Sieve Email Filtering: Variables Extension", RFC 5229, January 2008.

[RFC5229]Homme,K.,“筛选电子邮件过滤:变量扩展”,RFC5292008年1月。

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

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

[RFC5293] Degener, J. and P. Guenther, "Sieve Email Filtering: Editheader Extension", RFC 5293, August 2008.

[RFC5293]Degener,J.和P.Guenther,“筛选电子邮件过滤:Editheader扩展”,RFC 5293,2008年8月。

[RFC5322] Resnick, P., Ed., "Internet Message Format", RFC 5322, October 2008.

[RFC5322]Resnick,P.,Ed.“互联网信息格式”,RFC5222008年10月。

13.2. Informative References
13.2. 资料性引用

[RFC1991] Atkins, D., Stallings, W., and P. Zimmermann, "PGP Message Exchange Formats", RFC 1991, August 1996.

[RFC1991]Atkins,D.,Stallings,W.,和P.Zimmermann,“PGP消息交换格式”,RFC 1991,1996年8月。

[RFC3851] Ramsdell, B., "Secure/Multipurpose Internet Mail Extensions (S/MIME) Version 3.1 Message Specification", RFC 3851, July 2004.

[RFC3851]Ramsdell,B.,“安全/多用途Internet邮件扩展(S/MIME)版本3.1消息规范”,RFC 38512004年7月。

[RFC4871] Allman, E., Callas, J., Delany, M., Libbey, M., Fenton, J., and M. Thomas, "DomainKeys Identified Mail (DKIM) Signatures", RFC 4871, May 2007.

[RFC4871]Allman,E.,Callas,J.,Delany,M.,Libbey,M.,Fenton,J.,和M.Thomas,“域密钥识别邮件(DKIM)签名”,RFC 48712007年5月。

[RFC4880] Callas, J., Donnerhacke, L., Finney, H., Shaw, D., and R. Thayer, "OpenPGP Message Format", RFC 4880, November 2007.

[RFC4880]Callas,J.,Donnerhacke,L.,Finney,H.,Shaw,D.,和R.Thayer,“OpenPGP消息格式”,RFC 48802007年11月。

Authors' Addresses

作者地址

Tony Hansen AT&T Laboratories 200 Laurel Ave. Middletown, NJ 07748 USA

美国新泽西州米德尔顿劳雷尔大道200号托尼·汉森AT&T实验室,邮编:07748

   EMail: tony+sieveloop@maillennium.att.com
        
   EMail: tony+sieveloop@maillennium.att.com
        

Cyrus Daboo Apple Inc. 1 Infinite Loop Cupertino, CA 95014 USA

Cyrus Daboo苹果公司,美国加利福尼亚州库珀蒂诺市无限环路1号,邮编95014

   EMail: cyrus@daboo.name
   URI:   http://www.apple.com/
        
   EMail: cyrus@daboo.name
   URI:   http://www.apple.com/