dovecot-2.1-pigeonhole: Added editheader support.

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Thu Nov 24 01:25:48 EET 2011


details:   http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/253a0672ad92
changeset: 1549:253a0672ad92
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Thu Nov 24 00:24:47 2011 +0100
description:
Added editheader support.

diffstat:

 Makefile.am                                              |     4 +
 README                                                   |     2 +-
 TODO                                                     |     2 +
 configure.in                                             |     1 +
 doc/rfc/editheader.rfc5293.txt                           |   507 +++++
 src/lib-sieve/Makefile.am                                |     4 +
 src/lib-sieve/cmd-keep.c                                 |     3 +
 src/lib-sieve/cmd-redirect.c                             |    18 +-
 src/lib-sieve/edit-mail.c                                |  1704 +++++++++++++++++++
 src/lib-sieve/edit-mail.h                                |    46 +
 src/lib-sieve/ext-fileinto.c                             |     3 +
 src/lib-sieve/plugins/Makefile.am                        |     1 +
 src/lib-sieve/plugins/editheader/Makefile.am             |    16 +
 src/lib-sieve/plugins/editheader/cmd-addheader.c         |   252 ++
 src/lib-sieve/plugins/editheader/cmd-deleteheader.c      |   532 ++++++
 src/lib-sieve/plugins/editheader/ext-editheader-common.c |    28 +
 src/lib-sieve/plugins/editheader/ext-editheader-common.h |    33 +
 src/lib-sieve/plugins/editheader/ext-editheader.c        |    67 +
 src/lib-sieve/rfc2822.c                                  |   124 +-
 src/lib-sieve/rfc2822.h                                  |     4 +
 src/lib-sieve/sieve-actions.c                            |    18 +-
 src/lib-sieve/sieve-actions.h                            |     1 +
 src/lib-sieve/sieve-extensions.c                         |     4 +-
 src/lib-sieve/sieve-interpreter.c                        |     1 +
 src/lib-sieve/sieve-match-types.c                        |    22 +
 src/lib-sieve/sieve-match-types.h                        |     3 +
 src/lib-sieve/sieve-message.c                            |    56 +-
 src/lib-sieve/sieve-message.h                            |    10 +
 src/lib-sieve/sieve-result.c                             |     2 +
 src/lib-sieve/tst-exists.c                               |     5 +-
 src/lib-sieve/tst-size.c                                 |     6 +-
 src/testsuite/testsuite-message.c                        |    28 +-
 tests/extensions/editheader/addheader.svtest             |   323 +++
 tests/extensions/editheader/alternating.svtest           |   122 +
 tests/extensions/editheader/deleteheader.svtest          |   833 +++++++++
 tests/extensions/editheader/utf8.svtest                  |    49 +
 36 files changed, 4756 insertions(+), 78 deletions(-)

diffs (truncated from 5435 to 300 lines):

diff -r c94b71745f38 -r 253a0672ad92 Makefile.am
--- a/Makefile.am	Sat Nov 19 17:51:03 2011 +0100
+++ b/Makefile.am	Thu Nov 24 00:24:47 2011 +0100
@@ -126,6 +126,10 @@
 	tests/extensions/ihave/execute.svtest \
 	tests/extensions/ihave/errors.svtest \
 	tests/extensions/ihave/restrictions.svtest \
+	tests/extensions/editheader/addheader.svtest \
+	tests/extensions/editheader/deleteheader.svtest \
+	tests/extensions/editheader/alternating.svtest \
+	tests/extensions/editheader/utf8.svtest \
 	tests/extensions/vnd.dovecot/debug/execute.svtest \
 	tests/deprecated/notify/basic.svtest \
 	tests/deprecated/notify/mailto.svtest \
diff -r c94b71745f38 -r 253a0672ad92 README
--- a/README	Sat Nov 19 17:51:03 2011 +0100
+++ b/README	Thu Nov 24 00:24:47 2011 +0100
@@ -112,6 +112,7 @@
     spamtest and virustest (RFC 5235): fully supported (v0.1.16+), but
         currently considered experimental.
     date (RFC 5260; Section 4): fully supported (v0.1.12+).
+    editheader (RFC 5293): fully supported (v0.3.0+).
     reject (RFC 5429; Section 2.2): fully supported.
     enotify (RFC 5435): fully supported (v0.1.3+).
         mailto method (RFC 5436): fully supported (v0.1.3+).
@@ -142,7 +143,6 @@
   author has taken notice of the following extensions:
 
     index (RFC 5260; page 7): planned.
-    editheader (RFC 5293): planned.
     foreverypart, mime, replace, enclose, and extracttext (RFC 5703): planned.
 
     These extensions will be added as soon as the necessary infrastructure is
diff -r c94b71745f38 -r 253a0672ad92 TODO
--- a/TODO	Sat Nov 19 17:51:03 2011 +0100
+++ b/TODO	Thu Nov 24 00:24:47 2011 +0100
@@ -1,6 +1,8 @@
 Current activities:
 
 * Implement editheader extension
+	- Add header value verification to addheader command
+	- Add testsuite items for various error conditions 
 
 Parallel plugin-based efforts:
 
diff -r c94b71745f38 -r 253a0672ad92 configure.in
--- a/configure.in	Sat Nov 19 17:51:03 2011 +0100
+++ b/configure.in	Thu Nov 24 00:24:47 2011 +0100
@@ -118,6 +118,7 @@
 src/lib-sieve/plugins/date/Makefile
 src/lib-sieve/plugins/spamvirustest/Makefile
 src/lib-sieve/plugins/ihave/Makefile
+src/lib-sieve/plugins/editheader/Makefile
 src/lib-sieve/plugins/vnd.dovecot/Makefile
 src/lib-sieve/plugins/vnd.dovecot/debug/Makefile
 src/lib-sieve-tool/Makefile
diff -r c94b71745f38 -r 253a0672ad92 doc/rfc/editheader.rfc5293.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/rfc/editheader.rfc5293.txt	Thu Nov 24 00:24:47 2011 +0100
@@ -0,0 +1,507 @@
+
+
+
+
+
+
+Network Working Group                                         J. Degener
+Request for Comments: 5293                                   P. Guenther
+Category: Standards Track                                 Sendmail, Inc.
+                                                             August 2008
+
+
+              Sieve Email Filtering: Editheader Extension
+
+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.
+
+Abstract
+
+   This document defines two new actions for the "Sieve" email filtering
+   language that add and delete email header fields.
+
+1.  Introduction
+
+   Email header fields are a flexible and easy-to-understand means of
+   communication between email processors.  This extension enables sieve
+   scripts to interact with other components that consume or produce
+   header fields by allowing the script to delete and add header fields.
+
+2.  Conventions Used in This Document
+
+   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 [KEYWORDS].
+
+   Conventions for notations are as in Section 1.1 of [SIEVE], including
+   use of the "Usage:" label for the definition of action and tagged
+   arguments syntax.
+
+   The term "header field" is used here as in [IMAIL] to mean a logical
+   line of an email message header.
+
+3.  Capability Identifier
+
+   The capability string associated with the extension defined in this
+   document is "editheader".
+
+
+
+
+
+
+Degener & Guenther          Standards Track                     [Page 1]
+
+RFC 5293      Sieve Email Filtering: Editheader Extension    August 2008
+
+
+4.  Action addheader
+
+   Usage: "addheader" [":last"] <field-name: string> <value: string>
+
+   The addheader action adds a header field to the existing message
+   header.  If the field-name is not a valid 7-bit US-ASCII header field
+   name, as described by the [IMAIL] "field-name" nonterminal syntax
+   element, the implementation MUST flag an error.  The addheader action
+   does not affect Sieve's implicit keep.
+
+   If the specified field value does not match the [IMAIL]
+   "unstructured" nonterminal syntax element or exceeds a length limit
+   set by the implementation, the implementation MUST either flag an
+   error or encode the field using folding white space and the encodings
+   described in [MIME3] or [MIMEPARAM] to be compliant with [IMAIL].
+
+   An implementation MAY impose a length limit onto the size of the
+   encoded header field; such a limit MUST NOT be less than 998
+   characters, not including the terminating CRLF supplied by the
+   implementation.
+
+   By default, the header field is inserted at the beginning of the
+   existing message header.  If the optional flag ":last" is specified,
+   it is appended at the end.
+
+   Example:
+
+        /* Don't redirect if we already redirected */
+        if not header :contains "X-Sieve-Filtered"
+                ["<kim at job.example.com>", "<kim at home.example.com>"]
+        {
+                addheader "X-Sieve-Filtered" "<kim at job.example.com>";
+                redirect "kim at home.example.com";
+        }
+
+5.  Action deleteheader
+
+      Usage: "deleteheader" [":index" <fieldno: number> [":last"]]
+                   [COMPARATOR] [MATCH-TYPE]
+                   <field-name: string>
+                   [<value-patterns: string-list>]
+
+   By default, the deleteheader action deletes all occurrences of the
+   named header field.  The deleteheader action does not affect Sieve's
+   implicit keep.
+
+
+
+
+
+
+Degener & Guenther          Standards Track                     [Page 2]
+
+RFC 5293      Sieve Email Filtering: Editheader Extension    August 2008
+
+
+   The field-name is mandatory and always matched as a case-insensitive
+   US-ASCII string.  If the field-name is not a valid 7-bit header field
+   name as described by the [IMAIL] "field-name" nonterminal syntax
+   element, the implementation MUST flag an error.
+
+   The value-patterns, if specified, restrict which occurrences of the
+   header field are deleted to those whose values match any of the
+   specified value-patterns, the matching being according to the match-
+   type and comparator and performed as if by the "header" test.  In
+   particular, leading and trailing whitespace in the field values is
+   ignored.  If no value-patterns are specified, then the comparator and
+   match-type options are silently ignored.
+
+   If :index <fieldno> is specified, the attempts to match a value are
+   limited to the <fieldno> occurrence of the named header field,
+   beginning at 1, the first named header field.  If :last is specified,
+   the count is backwards; 1 denotes the last named header field, 2 the
+   second to last, and so on.  The counting happens before the <value-
+   patterns> match, if any.  For example:
+
+      deleteheader :index 1 :contains "Delivered-To"
+                              "bob at example.com";
+
+   deletes the first "Delivered-To" header field if it contains the
+   string "bob at example.com" (not the first "Delivered-To" field that
+   contains "bob at example.com").
+
+   It is not an error if no header fields match the conditions in the
+   deleteheader action or if the :index argument is greater than the
+   number of named header fields.
+
+   The implementation MUST flag an error if :last is specified without
+   also specifying :index.
+
+6.  Implementation Limitations on Changes
+
+   As a matter of local policy, implementations MAY limit which header
+   fields may be deleted and which header fields may be added.  However,
+   implementations MUST NOT permit attempts to delete "Received" and
+   "Auto-Submitted" header fields and MUST permit both addition and
+   deletion of the "Subject" header field.
+
+   If a script tries to make a change that isn't permitted, the attempt
+   MUST be silently ignored.
+
+
+
+
+
+
+
+Degener & Guenther          Standards Track                     [Page 3]
+
+RFC 5293      Sieve Email Filtering: Editheader Extension    August 2008
+
+
+7.  Interaction with Other Sieve Extensions
+
+   Actions that generate [MDN], [DSN], or similar disposition messages
+   MUST do so using the original, unmodified message header.  Similarly,
+   if an error terminates processing of the script, the original message
+   header MUST be used when doing the implicit keep required by Section
+   2.10.6 of [SIEVE].
+
+   All other actions that store, send, or alter the message MUST do so
+   with the current set of header fields.  This includes the addheader
+   and deleteheader actions themselves.  For example, the following
+   leaves the message unchanged:
+
+      addheader "X-Hello" "World";
+      deleteheader :index 1 "X-Hello";
+
+   Similarly, given a message with three or more "X-Hello" header
+   fields, the following example deletes the first and third of them,
+   not the first and second:
+
+      deleteheader :index 1 "X-Hello";
+      deleteheader :index 2 "X-Hello";
+
+   Tests and actions such as "exists", "header", or "vacation"
+   [VACATION] that examine header fields MUST examine the current state
+   of a header as modified by any actions that have taken place so far.
+
+   As an example, the "header" test in the following fragment will
+   always evaluate to true, regardless of whether or not the incoming
+   message contained an "X-Hello" header field:
+
+      addheader "X-Hello" "World";
+      if header :contains "X-Hello" "World"
+      {
+              fileinto "international";
+      }
+
+   However, if the presence or value of a header field affects how the
+   implementation parses or decodes other parts of the message, then,
+   for the purposes of that parsing or decoding, the implementation MAY
+   ignore some or all changes made to those header fields.  For example,
+   in an implementation that supports the [BODY] extension, "body" tests
+   may be unaffected by deleting or adding "Content-Type" or "Content-
+   Transfer-Encoding" header fields.  This does not rescind the
+   requirement that changes to those header fields affect direct tests;
+   only the semantic side effects of changes to the fields may be
+   ignored.
+
+
+
+
+Degener & Guenther          Standards Track                     [Page 4]
+
+RFC 5293      Sieve Email Filtering: Editheader Extension    August 2008
+
+
+   For the purpose of weeding out duplicates, a message modified by
+   addheader or deleteheader MUST be considered the same as the original
+   message.  For example, in an implementation that obeys the constraint
+   in Section 2.10.3 of [SIEVE] and does not deliver the same message to
+   a folder more than once, the following code fragment
+
+      keep;
+      addheader "X-Flavor" "vanilla";
+      keep;
+


More information about the dovecot-cvs mailing list