Internet Engineering Task Force (IETF)                       A. Melnikov
Request for Comments: 6558                                 Isode Limited
Category: Standards Track                                       B. Leiba
ISSN: 2070-1721                                                    K. Li
                                                     Huawei Technologies
                                                              March 2012
        
Internet Engineering Task Force (IETF)                       A. Melnikov
Request for Comments: 6558                                 Isode Limited
Category: Standards Track                                       B. Leiba
ISSN: 2070-1721                                                    K. Li
                                                     Huawei Technologies
                                                              March 2012
        

Sieve Extension for Converting Messages before Delivery

用于在传递前转换邮件的筛选扩展

Abstract

摘要

This document describes how the "CONVERT" IMAP extension can be used within the Sieve mail filtering language to transform messages before final delivery.

本文档描述了如何在Sieve邮件过滤语言中使用“CONVERT”IMAP扩展来在最终传递之前转换邮件。

Status of This Memo

关于下段备忘

This is an Internet Standards Track document.

这是一份互联网标准跟踪文件。

This document is a product of the Internet Engineering Task Force (IETF). It represents the consensus of the IETF community. It has received public review and has been approved for publication by the Internet Engineering Steering Group (IESG). Further information on Internet Standards is available in Section 2 of RFC 5741.

本文件是互联网工程任务组(IETF)的产品。它代表了IETF社区的共识。它已经接受了公众审查,并已被互联网工程指导小组(IESG)批准出版。有关互联网标准的更多信息,请参见RFC 5741第2节。

Information about the current status of this document, any errata, and how to provide feedback on it may be obtained at http://www.rfc-editor.org/info/rfc6558.

有关本文件当前状态、任何勘误表以及如何提供反馈的信息,请访问http://www.rfc-editor.org/info/rfc6558.

Copyright Notice

版权公告

Copyright (c) 2012 IETF Trust and the persons identified as the document authors. All rights reserved.

版权所有(c)2012 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 Simplified BSD License.

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

Table of Contents

目录

   1. Introduction ....................................................2
      1.1. Conventions Used in This Document ..........................2
   2. "convert" Action ................................................2
      2.1. Interaction with Other Tests and Actions ...................3
      2.2. "convert" as a Test ........................................4
   3. Examples ........................................................5
      3.1. Example 1 ..................................................5
      3.2. Example 2 ..................................................5
      3.3. Example 3 ..................................................5
      3.4. Example 4 ..................................................6
   4. Security Considerations .........................................7
   5. IANA Considerations .............................................7
   6. Acknowledgements ................................................7
   7. Normative References ............................................7
        
   1. Introduction ....................................................2
      1.1. Conventions Used in This Document ..........................2
   2. "convert" Action ................................................2
      2.1. Interaction with Other Tests and Actions ...................3
      2.2. "convert" as a Test ........................................4
   3. Examples ........................................................5
      3.1. Example 1 ..................................................5
      3.2. Example 2 ..................................................5
      3.3. Example 3 ..................................................5
      3.4. Example 4 ..................................................6
   4. Security Considerations .........................................7
   5. IANA Considerations .............................................7
   6. Acknowledgements ................................................7
   7. Normative References ............................................7
        
1. Introduction
1. 介绍

The IMAP "CONVERT" extension [RFC5259] adds an IMAP command for performing client-controlled conversions on whole messages or their body parts. This document defines a similar extension to the Sieve mail filtering language [RFC5228], which reuses the conversion parameters and framework established by IMAP CONVERT.

IMAP“CONVERT”扩展[RFC5259]添加了一个IMAP命令,用于对整个消息或其正文部分执行客户端控制的转换。本文档定义了与筛邮件过滤语言[RFC5228]类似的扩展,该语言重用由IMAP CONVERT建立的转换参数和框架。

1.1. Conventions Used in This Document
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 RFC 2119 [RFC2119].

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

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

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

2. "convert" Action
2. “转换”操作
   Usage: convert  <quoted-from-media-type: string>
                   <quoted-to-media-type: string>
                   <transcoding-params: string-list>
        
   Usage: convert  <quoted-from-media-type: string>
                   <quoted-to-media-type: string>
                   <transcoding-params: string-list>
        

The "convert" action specifies that all body parts with a media type [RFC2046] (sometimes called "MIME type") equal to <quoted-from-media-type> be converted to the media type in <quoted-to-media-type> using conversion parameters specified in <transcoding-params>. Each conversion parameter value has the following syntax: "<transcoding-param-name>=<transcoding-param-value>", where <transcoding-param-name> and <transcoding-param-value> are defined in CONVERT [RFC5259]. Messages that don't have any body parts with the <quoted-from-media-type> media type are not affected by the conversion.

“转换”操作指定使用<transcoding params>中指定的转换参数将媒体类型[RFC2046](有时称为“MIME类型”)等于<quoted from media type>的所有正文部分转换为<quoted to media type>中的媒体类型。每个转换参数值都有以下语法:“<transcoding param name>=<transcoding param value>”,其中<transcoding param name>和<transcoding param value>在CONVERT[RFC5259]中定义。没有任何带有<quoted from media type>媒体类型的正文部分的邮件不受转换的影响。

The "convert" action can be used with Sieve MIME Part Tests [RFC5703], in the case that some, but not all of the body parts need to be converted, or where different body parts might require different conversions. When the "convert" action appears in a "foreverypart" loop, it applies only to the body part being processed, and not to any other body parts (see Section 3.2 for an example).

“转换”操作可用于筛MIME零件测试[RFC5703],前提是某些但不是所有的车身零件需要转换,或者不同的车身零件可能需要不同的转换。当“convert”动作出现在“foreverypart”循环中时,它仅适用于正在处理的身体部位,而不适用于任何其他身体部位(示例见第3.2节)。

When the "convert" action appears outside a "foreverypart" loop, the conversion applies equally to all body parts -- that is, all body parts that have the "quoted-from-media-type" are converted, using the same transcoding parameters.

当“convert”操作出现在“foreverypart”循环之外时,转换将平等地应用于所有身体部位——也就是说,使用相同的转码参数转换具有“quoted from media type”的所有身体部位。

A single "convert" action will only apply once to any body part. If, for example, << convert "image/jpeg" "image/jpeg" ["pix-x=100","pix-y=120"] >> converts a larger JPEG image to the smaller 100 x 120 size, that will be the end of that "convert" action on that body part. The action will not see a "new" JPEG body part to process, resulting from the conversion.

单个“转换”操作仅对任何身体部位应用一次。例如,如果<convert“image/jpeg”“image/jpeg”[“pix-x=100”,“pix-y=120”]>>将较大的jpeg图像转换为较小的100 x 120大小,则该身体部位的“convert”操作将结束。该操作将不会看到要处理的“新”JPEG正文部分,这是由转换产生的。

If a "convert" action cannot be completed -- perhaps because the conversion failed, or because the requested conversion is not available -- that "convert" action MUST terminate and leave the message unchanged, rolling back any other conversions done by that action. The script processing continues, and prior or subsequent "convert" actions are not affected. No error condition is raised, and no partial conversions from a single "convert" action are allowed.

如果“转换”操作无法完成(可能是因为转换失败,或者因为请求的转换不可用),“转换”操作必须终止并保持消息不变,回滚该操作完成的任何其他转换。脚本处理将继续,之前或后续的“转换”操作不受影响。不会引发错误条件,并且不允许从单个“转换”操作进行部分转换。

Implementations might defer any actual conversion until the results of the conversion are needed for script processing, to avoid doing conversions unnecessarily. Consider the case wherein a "convert" action is processed but a "discard" action results without the need to actually perform the conversion.

实现可能会推迟任何实际转换,直到脚本处理需要转换的结果,以避免不必要地进行转换。考虑一个“转换”操作被处理但一个“丢弃”动作结果而不需要实际执行转换的情况。

When conversions actually need to be done, they can put a significant load on the server. Computationally expensive conversions of a lot of body parts can constitute an attack vector; even if done legitimately, they can create an unacceptable load. Servers MAY refuse conversions, or do them at lower priority, effectively slowing the requesting process in order to avoid negative effects on service to other processes.

当实际需要进行转换时,它们会给服务器带来很大的负载。计算大量昂贵的身体部分的转换可以构成攻击向量;即使这样做是合法的,它们也会产生不可接受的负载。服务器可能会拒绝转换,或者以较低的优先级进行转换,从而有效地减慢请求进程,以避免对其他进程的服务产生负面影响。

2.1. Interaction with Other Tests and Actions
2.1. 与其他测试和操作的交互

Whether or not the actual conversion has been done yet, a successful "convert" action effectively changes the message, and all subsequent actions, including any other "convert" actions, apply to the changed

无论实际转换是否已完成,成功的“转换”操作都会有效地更改消息,并且所有后续操作(包括任何其他“转换”操作)都将应用于更改的消息

message. The "convert" action does not affect the applicability of other actions; any action that was applicable before the "convert" is equally applicable to the changed message afterward.

消息“转换”操作不影响其他操作的适用性;在“转换”之前适用的任何操作都同样适用于之后更改的消息。

When a disposition-type action, such as "fileinto" or "redirect", is encountered, the state of the message with respect to conversions is "locked in" for that disposition-type action. Whether the implementation performs the action at that point or batches it for later, it MUST perform the action on the message as it stood at the time, and MUST NOT include subsequent conversions encountered later in the script processing. Therefore, the sequence "convert, fileinto, convert, fileinto" will store two different versions of the message: the first "fileinto" uses only the first conversion, while the second uses both. See Section 3.4 for an example of how this can be used.

当遇到处置类型操作(如“fileinto”或“redirect”)时,该处置类型操作的转换消息状态为“锁定”。无论实现是在该点执行操作,还是在以后对其进行批处理,它都必须按当时的状态对消息执行操作,并且不得包括稍后在脚本处理中遇到的后续转换。因此,序列“convert,fileinto,convert,fileinto”将存储消息的两个不同版本:第一个“fileinto”仅使用第一个转换,而第二个使用两个。有关如何使用的示例,请参见第3.4节。

In addition, any tests done on the message and its parts will test the message after prior conversions have been done. The fourth block of Section 3.4 shows an example of this situation.

此外,对消息及其部分所做的任何测试都将在之前的转换完成后测试消息。第3.4节的第四块显示了这种情况的示例。

Convert actions are cumulative, and each conversion operates on the message as it stands after all prior conversions. See the fourth block of Section 3.4 for an example of how this might be tricky.

转换操作是累积的,每次转换都会对之前所有转换后的消息进行操作。请参阅第3.4节的第四部分,以了解这可能是多么棘手的一个示例。

Because the implicit keep (see Section 2.10.2 of [RFC5228]), if it is in effect, acts on the final state of the message, all conversions are performed before any implicit keep.

由于隐式保留(见[RFC5228]第2.10.2节)如果有效,则作用于消息的最终状态,因此所有转换都在任何隐式保留之前执行。

2.2. "convert" as a Test
2.2. “转换”作为测试

To simplify testing for supported and successful conversions, the "convert" action can also be used as a test. As such, it will attempt to perform the requested conversion(s) and will evaluate to "false" if and only if at least one conversion failed. The failure can be because a conversion was unsupported or because the data could not be converted (perhaps it had been corrupted in transit or mislabeled at its origin).

为了简化受支持和成功转换的测试,“转换”操作也可以用作测试。因此,当且仅当至少一次转换失败时,它将尝试执行请求的转换,并将计算为“false”。失败的原因可能是不支持转换或无法转换数据(可能是数据在传输过程中损坏或在源位置标记错误)。

This creates a new type of Sieve action, a "testable action". The usage as a test is exactly the same as for an action, and it doubles as an action and a test of the action's result at the same time. See Section 3.2 for an example of how this test can be used.

这就产生了一种新的筛选行为,即“可测试行为”。作为测试的用法与作为操作的用法完全相同,它同时作为操作和操作结果的测试。有关如何使用该测试的示例,请参见第3.2节。

Note that defining this new testable action does not change the definitions of any other actions -- it does not imply that other actions can be used as tests. Future extensions might define other testable actions, but those specifications would be responsible for clearly specifying that.

请注意,定义这个新的可测试操作不会改变任何其他操作的定义——它并不意味着其他操作可以用作测试。未来的扩展可能会定义其他可测试的操作,但这些规范将负责明确指定这些操作。

3. Examples
3. 例子
3.1. Example 1
3.1. 例1

In the following example, all "image/tiff" body parts of the message are converted to "image/jpeg" with image resolution of 320x240 pixels. The converted message is then subject to the implicit keep.

在以下示例中,消息的所有“图像/tiff”正文部分都转换为图像分辨率为320x240像素的“图像/jpeg”。然后,转换后的消息将接受隐式保留。

       require ["convert"];
       convert "image/tiff" "image/jpeg" ["pix-x=320","pix-y=240"];
        
       require ["convert"];
       convert "image/tiff" "image/jpeg" ["pix-x=320","pix-y=240"];
        
3.2. Example 2
3.2. 例2

In the following example, all "image/tiff" body parts of the message are converted to "image/jpeg", as in Example 1. If the conversions were successful, those messages are then filed into a mailbox called "INBOX.pics". Other messages (those with no image/tiff body parts) are subject to the implicit keep, and have not been converted.

在下面的示例中,消息的所有“image/tiff”正文部分都转换为“image/jpeg”,如示例1所示。如果转换成功,这些邮件将被归档到名为“INBOX.pics”的邮箱中。其他消息(没有图像/tiff正文部分的消息)受隐式保留约束,尚未转换。

       require ["mime", "fileinto", "convert"];
       if header :mime :anychild :contenttype
                 "Content-Type" "image/tiff"
       {
        if (convert "image/tiff" "image/jpeg" ["pix-x=320","pix-y=240"])
        {
         fileinto "INBOX.pics";
        }
       }
        
       require ["mime", "fileinto", "convert"];
       if header :mime :anychild :contenttype
                 "Content-Type" "image/tiff"
       {
        if (convert "image/tiff" "image/jpeg" ["pix-x=320","pix-y=240"])
        {
         fileinto "INBOX.pics";
        }
       }
        
3.3. Example 3
3.3. 例3

In the following example, only "image/tiff" body parts with a Content-Disposition of "inline" are converted. Matching parts that are larger than 500 kilobytes are converted using an image resolution of 640x480 pixels, and those smaller are converted to 320x240 pixels. The message disposition is not changed, so the implicit keep will be in effect unless something else in the script changes that.

在以下示例中,仅转换内容配置为“inline”的“image/tiff”主体部分。大于500千字节的匹配部分使用640x480像素的图像分辨率进行转换,较小的部分转换为320x240像素。消息配置没有更改,因此隐式保留将生效,除非脚本中的其他内容更改该设置。

       require ["mime", "foreverypart", "fileinto", "convert"];
       foreverypart
       {
         if header :mime :param "filename" :contains
                   "Content-Disposition" "inline"
         {
           if size :over "500K"
           {
            convert "image/tiff" "image/jpeg" ["pix-x=640","pix-y=480"];
           } else {
        
       require ["mime", "foreverypart", "fileinto", "convert"];
       foreverypart
       {
         if header :mime :param "filename" :contains
                   "Content-Disposition" "inline"
         {
           if size :over "500K"
           {
            convert "image/tiff" "image/jpeg" ["pix-x=640","pix-y=480"];
           } else {
        
            convert "image/tiff" "image/jpeg" ["pix-x=320","pix-y=240"];
           }
         }
       }
        
            convert "image/tiff" "image/jpeg" ["pix-x=320","pix-y=240"];
           }
         }
       }
        

[... script continues ...]

[…脚本继续…]

3.4. Example 4
3.4. 例4

The following example shows some tricky interactions between multiple "convert" actions and other disposition-type actions.

以下示例显示了多个“转换”操作和其他处置类型操作之间的一些复杂交互。

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

要求[“mime”、“永久部分”、“文件导入”、“重定向”、“转换”];

       # The first "if" block will convert all image/tiff body parts
       # to 640x480 jpegs and will file the message
       # into the "INBOX.pics" mailbox as converted at this point.
       if header :mime :anychild :contenttype
                 "Content-Type" "image/tiff"
       {
         convert "image/tiff" "image/jpeg" ["pix-x=640","pix-y=480"];
         fileinto "INBOX.pics";
       }
        
       # The first "if" block will convert all image/tiff body parts
       # to 640x480 jpegs and will file the message
       # into the "INBOX.pics" mailbox as converted at this point.
       if header :mime :anychild :contenttype
                 "Content-Type" "image/tiff"
       {
         convert "image/tiff" "image/jpeg" ["pix-x=640","pix-y=480"];
         fileinto "INBOX.pics";
       }
        
       # The second block, the "foreverypart" loop, will convert all
       # inline jpegs to 320x240 resolution... including any tiff body
       # parts that had been converted in the first block, above.
       # Therefore, any tiff that had been converted to a 640x480 jpeg
       # will be re-converted to a 320x240 jpeg here if its
       # Content-Disposition is specified as "inline".
       foreverypart
       {
         if header :mime :param "filename" :contains
                   "Content-Disposition" "inline"
         {
           convert "image/jpeg" "image/jpeg" ["pix-x=320","pix-y=240"];
         }
       }
        
       # The second block, the "foreverypart" loop, will convert all
       # inline jpegs to 320x240 resolution... including any tiff body
       # parts that had been converted in the first block, above.
       # Therefore, any tiff that had been converted to a 640x480 jpeg
       # will be re-converted to a 320x240 jpeg here if its
       # Content-Disposition is specified as "inline".
       foreverypart
       {
         if header :mime :param "filename" :contains
                   "Content-Disposition" "inline"
         {
           convert "image/jpeg" "image/jpeg" ["pix-x=320","pix-y=240"];
         }
       }
        
       # The third block will take any message that contains a header
       # field called "Mobile-Link" and redirect it to the user's
       # mobile address.  The redirected message will include both
       # conversions above, from block one and block two.
       if exists "Mobile-Link"
       {
         redirect "joe@mobile.example.com";
       }
        
       # The third block will take any message that contains a header
       # field called "Mobile-Link" and redirect it to the user's
       # mobile address.  The redirected message will include both
       # conversions above, from block one and block two.
       if exists "Mobile-Link"
       {
         redirect "joe@mobile.example.com";
       }
        
       # The fourth block will file the message into "Tiff" if it
       # contains any tiff body parts.  But because of the earlier
       # conversion (in the first block), there will never be any
       # tiff body parts, so this "fileinto" will never happen.
       if header :mime :anychild :contenttype
                 "Content-Type" "image/tiff"
       {
         fileinto "Tiff";
       }
        
       # The fourth block will file the message into "Tiff" if it
       # contains any tiff body parts.  But because of the earlier
       # conversion (in the first block), there will never be any
       # tiff body parts, so this "fileinto" will never happen.
       if header :mime :anychild :contenttype
                 "Content-Type" "image/tiff"
       {
         fileinto "Tiff";
       }
        

# Now, at the end of the script processing, the Sieve # processor will perform an implicit keep if none of # the "fileinto" and "redirect" actions were taken. # The kept message will include any conversions that # were done (that is, any from the second block).

#现在,在脚本处理结束时,如果没有执行任何“fileinto”和“redirect”操作,Sieve处理器将执行隐式keep保留的消息将包括#已完成的任何转换(即,来自第二个块的任何转换)。

4. Security Considerations
4. 安全考虑

Security considerations given in IMAP CONVERT [RFC5259] and Sieve [RFC5228] are relevant to this document. There are no additional security considerations resulting from combining the two.

IMAP转换[RFC5259]和筛选[RFC5228]中给出的安全注意事项与本文档相关。将两者结合起来不会产生额外的安全考虑。

5. IANA Considerations
5. IANA考虑

IANA has added the following registration to the "Sieve Extensions" registry, as defined in RFC 5228:

IANA已将以下注册添加到RFC 5228中定义的“筛网扩展”注册表中:

Capability name: convert Description: adds a new Sieve test and action that enable Sieve scripts to perform data conversions on the message being delivered. RFC number: RFC 6558 Contact address: The Sieve discussion list <sieve@ietf.org>

功能名称:转换描述:添加新的筛选测试和操作,使筛选脚本能够对所传递的消息执行数据转换。RFC编号:RFC 6558联系地址:筛讨论列表<sieve@ietf.org>

6. Acknowledgements
6. 致谢

The authors also want to thank all who have contributed key insight and extensively reviewed and discussed the concepts of CONVERT.

作者还想感谢所有对CONVERT的概念做出重要贡献并进行广泛回顾和讨论的人。

Qian Sun contributed text to this document.

钱孙为这份文件提供了文本。

7. Normative References
7. 规范性引用文件

[RFC2046] Freed, N. and N. Borenstein, "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types", RFC 2046, November 1996.

[RFC2046]Freed,N.和N.Borenstein,“多用途Internet邮件扩展(MIME)第二部分:媒体类型”,RFC 20461996年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月。

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

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

[RFC5259] Melnikov, A. and P. Coates, "Internet Message Access Protocol - CONVERT Extension", RFC 5259, July 2008.

[RFC5259]Melnikov,A.和P.Coates,“互联网消息访问协议-转换扩展”,RFC 5259,2008年7月。

[RFC5703] Hansen, T. and C. Daboo, "Sieve Email Filtering: MIME Part Tests, Iteration, Extraction, Replacement, and Enclosure", RFC 5703, October 2009.

[RFC5703]Hansen,T.和C.Daboo,“筛选电子邮件过滤:MIME部分测试、迭代、提取、替换和封装”,RFC 57032009年10月。

Authors' Addresses

作者地址

Alexey Melnikov Isode Limited 5 Castle Business Village 36 Station Road Hampton, Middlesex TW12 2BX UK

英国米德尔塞克斯郡汉普顿车站路36号城堡商业村5号Alexey Melnikov Isode Limited TW12 2BX

   EMail: Alexey.Melnikov@isode.com
   URI:   http://www.melnikov.ca/
        
   EMail: Alexey.Melnikov@isode.com
   URI:   http://www.melnikov.ca/
        

Barry Leiba Huawei Technologies

巴里·雷巴华为技术有限公司

   Phone: +1 646 827 0648
   EMail: barryleiba@computer.org
   URI:   http://internetmessagingtechnology.org/
        
   Phone: +1 646 827 0648
   EMail: barryleiba@computer.org
   URI:   http://internetmessagingtechnology.org/
        

Kepeng Li Huawei Technologies Huawei Base, Bantian, Longgang District Shenzhen, Guangdong 518129 P. R. China

中国广东省深圳市龙岗区坂田李克鹏华为技术有限公司华为基地邮编:518129

   Phone: +86-755-28974289
   EMail: likepeng@huawei.com
        
   Phone: +86-755-28974289
   EMail: likepeng@huawei.com