draft-ietf-sieve-convert-03.txt   draft-ietf-sieve-convert-04.txt 
Sieve Working Group A. Melnikov Sieve Working Group A. Melnikov
Internet-Draft Isode Limited Internet-Draft Isode Limited
Intended status: Standards Track Q. Sun Intended status: Standards Track Q. Sun
Expires: March 22, 2012 B. Leiba Expires: March 27, 2012 B. Leiba
K. Li K. Li
Huawei Technologies Huawei Technologies
September 19, 2011 September 24, 2011
Sieve Extension for converting messages before delivery Sieve Extension for converting messages before delivery
draft-ietf-sieve-convert-03 draft-ietf-sieve-convert-04
Abstract Abstract
This document describes how IMAP CONVERT can be used within Sieve to This document describes how IMAP CONVERT can be used within Sieve to
transform messages before final delivery. transform messages before final delivery.
Status of this Memo Status of this Memo
This Internet-Draft is submitted in full conformance with the This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79. provisions of BCP 78 and BCP 79.
skipping to change at page 1, line 34 skipping to change at page 1, line 34
Internet-Drafts are working documents of the Internet Engineering Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet- working documents as Internet-Drafts. The list of current Internet-
Drafts is at http://datatracker.ietf.org/drafts/current/. Drafts is at http://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress." material or to cite them other than as "work in progress."
This Internet-Draft will expire on March 22, 2012. This Internet-Draft will expire on March 27, 2012.
Copyright Notice Copyright Notice
Copyright (c) 2011 IETF Trust and the persons identified as the Copyright (c) 2011 IETF Trust and the persons identified as the
document authors. All rights reserved. document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of (http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents publication of this document. Please review these documents
skipping to change at page 2, line 22 skipping to change at page 2, line 22
2.2. "convert" as a test . . . . . . . . . . . . . . . . . . . . . 4 2.2. "convert" as a test . . . . . . . . . . . . . . . . . . . . . 4
3. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.1. Example 1 . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.1. Example 1 . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.2. Example 2 . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.2. Example 2 . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.3. Example 3 . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.3. Example 3 . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.4. Example 4 . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.4. Example 4 . . . . . . . . . . . . . . . . . . . . . . . . . . 6
4. Security Considerations . . . . . . . . . . . . . . . . . . . 7 4. Security Considerations . . . . . . . . . . . . . . . . . . . 7
5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 8 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 7
6. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 8 6. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 8
7. Normative References . . . . . . . . . . . . . . . . . . . . 8 7. Normative References . . . . . . . . . . . . . . . . . . . . 8
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . 8 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . 8
1. Introduction 1. Introduction
The IMAP CONVERT extension [RFC5259] adds an IMAP command for The IMAP CONVERT extension [RFC5259] adds an IMAP command for
skipping to change at page 3, line 32 skipping to change at page 3, line 32
2. "convert" action 2. "convert" action
Usage: convert <quoted-from-mime-type: string> Usage: convert <quoted-from-mime-type: string>
<quoted-to-mime-type: string> <quoted-to-mime-type: string>
<transcoding-params: string-list> <transcoding-params: string-list>
The "convert" action specifies that body parts with "quoted-from- The "convert" action specifies that body parts with "quoted-from-
mime-type" MIME type be converted to "quoted-to-mime-type" MIME type mime-type" MIME type be converted to "quoted-to-mime-type" MIME type
using conversion parameters specified in "transcoding-params". Each using conversion parameters specified in "transcoding-params". Each
conversion parameter value has the following syntax: "<transcoding- conversion parameter value has the following syntax: "<transcoding-
param>=<transcoding-param-value>", where <transcoding-param> and param-name>=<transcoding-param-value>", where <transcoding-param-
<transcoding-param-value> are defined in CONVERT [RFC5259]. Messages name> and <transcoding-param-value> are defined in CONVERT [RFC5259].
that don't have any body parts with the "quoted-from-mime-type" MIME Messages that don't have any body parts with the "quoted-from-mime-
type are not affected by the conversion. type" MIME type are not affected by the conversion.
The "convert" action can be used with Sieve MIME Part Tests 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 [RFC5703], in the case that some, but not all of the body parts need
to be converted, or where different body parts might require to be converted, or where different body parts might require
different conversions. When the "convert" action appears in a different conversions. When the "convert" action appears in a
"foreverypart" loop, it applies only to the body part being "foreverypart" loop, it applies only to the body part being
processed, and not to any other body parts (see Section 3.2 for an processed, and not to any other body parts (see Section 3.2 for an
example). example).
When the "convert" action appears outside a "foreverypart" loop, the When the "convert" action appears outside a "foreverypart" loop, the
skipping to change at page 5, line 9 skipping to change at page 5, line 9
2.2. "convert" as a test 2.2. "convert" as a test
To simplify testing for supported and successful conversions, the To simplify testing for supported and successful conversions, the
"convert" action can also be used as a test. As such, it will "convert" action can also be used as a test. As such, it will
attempt to perform the requested conversion(s), and will evaluate to attempt to perform the requested conversion(s), and will evaluate to
"false" if and only if at least one conversion failed. The failure "false" if and only if at least one conversion failed. The failure
can be because a conversion was unsupported, or because the data can be because a conversion was unsupported, or because the data
could not be converted (perhaps it had been corrupted in transit, or could not be converted (perhaps it had been corrupted in transit, or
mislabelled at its origin). mislabelled at its origin).
This creates a new time of Sieve action, a "testable action". The 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 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 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. Section 3.2 for an example of how this test can be used.
Note that defining this new testable action does not change the Note that defining this new testable action does not change the
definitions of any other actions -- it does not imply that other definitions of any other actions -- it does not imply that other
actions can be used as tests. Future extensions might define other actions can be used as tests. Future extensions might define other
testable actions, but those specifications would be responsible for testable actions, but those specifications would be responsible for
clearly specifying that. clearly specifying that.
3. Examples 3. Examples
3.1. Example 1 3.1. Example 1
In the following example, all "image/tiff" body parts of the message In the following example, all "image/tiff" body parts of the message
are converted to "image/jpeg" with image resolution of 320x240 are converted to "image/jpeg" with image resolution of 320x240
pixels. The converted message is then subject to the implicit keep. pixels. The converted message is then subject to the implicit keep.
require ["convert"]; require ["convert"];
convert "image/tiff" "image/jpeg" "pix-x" "320" "pix-y" "240"; convert "image/tiff" "image/jpeg" ["pix-x=320","pix-y=240"];
3.2. Example 2 3.2. Example 2
In the following example, all "image/tiff" body parts of the message In the following example, all "image/tiff" body parts of the message
are converted to "image/jpeg", as in Example 1. If the conversions are converted to "image/jpeg", as in Example 1. If the conversions
were successful, those messages are then filed into a mailbox called were successful, those messages are then filed into a mailbox called
"INBOX.pics". Other messages (those with no image/tiff body parts) "INBOX.pics". Other messages (those with no image/tiff body parts)
are subject to the implicit keep, and have not been converted. are subject to the implicit keep, and have not been converted.
require ["mime", "fileinto", "convert"]; require ["mime", "fileinto", "convert"];
if header :mime :anychild :contenttype if header :mime :anychild :contenttype
"Content-Type" "image/tiff" "Content-Type" "image/tiff"
{ {
if (convert "image/tiff" "image/jpeg" if (convert "image/tiff" "image/jpeg" ["pix-x=320","pix-y=240"])
"pix-x" "320" "pix-y" "240") { {
fileinto "INBOX.pics"; fileinto "INBOX.pics";
} }
} }
3.3. Example 3 3.3. Example 3
In the following example, only "image/tiff" body parts with a In the following example, only "image/tiff" body parts with a
Content-Disposition of "inline" are converted. Matching parts that Content-Disposition of "inline" are converted. Matching parts that
are larger than 500 kilobytes are converted using an image resolution are larger than 500 kilobytes are converted using an image resolution
of 640x480 pixels, and those smaller are converted to 320x240 pixels. of 640x480 pixels, and those smaller are converted to 320x240 pixels.
The message disposition is not changed, so the implicit keep will be The message disposition is not changed, so the implicit keep will be
in effect unless something else in the script changes that. in effect unless something else in the script changes that.
require ["mime", "foreverypart", "fileinto", "convert"]; require ["mime", "foreverypart", "fileinto", "convert"];
foreverypart foreverypart
{ {
if header :mime :param "filename" :contains if header :mime :param "filename" :contains
"Content-Disposition" "inline" "Content-Disposition" "inline"
{ {
if size :over "500K" if size :over "500K"
{ {
convert "image/tiff" "image/jpeg" convert "image/tiff" "image/jpeg" ["pix-x=640","pix-y=480"];
"pix-x" "640" "pix-y" "480";
} else { } else {
convert "image/tiff" "image/jpeg" convert "image/tiff" "image/jpeg" ["pix-x=320","pix-y=240"];
"pix-x" "320" "pix-y" "240";
} }
} }
} }
[... script continues ...] [... script continues ...]
3.4. Example 4 3.4. Example 4
The following example shows some tricky interactions between multiple The following example shows some tricky interactions between multiple
"convert" actions and other disposition-type actions. "convert" actions and other disposition-type actions.
require ["mime", "foreverypart", require ["mime", "foreverypart",
"fileinto", "redirect" "convert"]; "fileinto", "redirect" "convert"];
# The first "if" block will convert all image/tiff body parts # The first "if" block will convert all image/tiff body parts
# to 640x480 jpegs, and will file the message # to 640x480 jpegs, and will file the message
# into the "INBOX.pics" mailbox as converted at this point. # into the "INBOX.pics" mailbox as converted at this point.
if header :mime :anychild :contenttype if header :mime :anychild :contenttype
"Content-Type" "image/tiff" "Content-Type" "image/tiff"
{ {
convert "image/tiff" "image/jpeg" "pix-x" "640" "pix-y" "480"; convert "image/tiff" "image/jpeg" ["pix-x=640","pix-y=480"];
fileinto "INBOX.pics"; fileinto "INBOX.pics";
} }
# The second block, the "foreverypart" loop, will convert all # The second block, the "foreverypart" loop, will convert all
# inline jpegs to 320x240 resolution... including any tiff body # inline jpegs to 320x240 resolution... including any tiff body
# parts that had been converted in the first block, above. # parts that had been converted in the first block, above.
# Therefore, any tiff that had been converted to a 640x480 jpeg # Therefore, any tiff that had been converted to a 640x480 jpeg
# will be re-converted to a 320x240 jpeg here if its # will be re-converted to a 320x240 jpeg here if its
# Content-Disposition is specified as "inline". # Content-Disposition is specified as "inline".
foreverypart foreverypart
{ {
if header :mime :param "filename" :contains if header :mime :param "filename" :contains
"Content-Disposition" "inline" "Content-Disposition" "inline"
{ {
convert "image/jpeg" "image/jpeg" convert "image/jpeg" "image/jpeg" ["pix-x=320","pix-y=240"];
"pix-x" "320" "pix-y" "240";
} }
} }
# The third block will take any message that contains a header # The third block will take any message that contains a header
# field called "Mobile-Link" and redirect it to the user's # field called "Mobile-Link" and redirect it to the user's
# mobile address. The redirected message will include both # mobile address. The redirected message will include both
# conversions above, from block one and block two. # conversions above, from block one and block two.
if exists "Mobile-Link" if exists "Mobile-Link"
{ {
redirect "joe@mobile.example.com"; redirect "joe@mobile.example.com";
 End of changes. 13 change blocks. 
22 lines changed or deleted 19 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/