Seems a lot of people have asked for this.
So, here's a bit of wording to play with.
Two issues I can think of:
- I really don't like applying regexes to something with
a comment and quote syntax.
Therefore, I'd like a :param parameter that can be used
to select a Content-Disposition or Content-Type parameter
(so you'd check for :param "filename" in the example)
rather than trying to just match them with :contains
or worse. (The grammar describing what :param means
can probably be done better.)
But maybe this is overkill.
- RFC 2047 prohibits RFC 2047-encoding of filenames.
(They're not the right kind of token.)
In reality, many clients do RFC 2047-encode and -decode names,
and I think sieve code matching against file names in order
to prevent use of certain extensions needs to, ironically,
RFC 2047-decode the wrong tokens in spite of what the RFC itself says.
I'm not sure about the right wording there.
Here's a hasty first draft:
Test mimeheader
Syntax: mimeheader [:param <params:string-list>] [COMPARATOR] [MATCH-TYPE]
<header-names: string-list> <key-list: string-list>
The "mimeheader" test evaluates to true if any of the values of
the named MIME headers match any of the keys. The type of match
is specified by the optional [MATCH-TYPE] argument, which defaults
to ":is", as specified in section 2.6 of [SIEVE].
Like the "header" test, this test returns true if any combination of the
string-list and key-list arguments match. Also like "header", a
MIME header listed in the header-names argument contains the
empty string key if and only if it exists.
Unlike the "header" test, the headers matching the "mimeheader" test
can occur either in the outermost RFC2822 header or in any of the
contained MIME parts. (They must occur in the header section of
a MIME part; the matching algorithm MUST disregard the text contained
in MIME bodies.)
If the optional :param keyword is present, all matching headers
are interpreted as if they had the syntax
*(token / <tspecial other than ;>) *(; name=value)
similar of the Content-Type and Content-Disposition header, and the
value used for the sake of comparison is that of the parameter whose
name case-insensitively matches any of the specified names.
Jutta <jutta(_at_)sendmail(_dot_)com>