On Tue, Oct 09, 2012 at 05:32:13PM +0200, Vincent Lefevre wrote:

> Do you mean that messages must completely follow RFC 5322,
> i.e. with each line ending with CRLF (not just LF)?

No, UNIX line endings are accepted with sendmail(1), postmap(1),
...  since that's how messages are stored on Unix. Other than
line endings however, the MIME parser processes RFC 2822 messages.

> Moreover since other tools (e.g. procmail) accept and/or generate
> messages starting with a "From " line, it would be better to output
> an error message if the message is regarded as invalid rather than
> failing silently.

The MIME parser in Postfix is for sendmail(1), smtpd(8) and smtp(8),
and does not get fed unix mbox format, there is no promise that
the MIME parser supports this format. The postfix sendmail(1) maps
"From_" to an RFC 822 header on input.

The postmap(1) utility feeds the MIME parser exactly what you ask
it to process. I think this is best, it is a testing tool, not a
message normalizer.

> Anyway, even without the "From " line (which was actually my first
> test, but the message was too large as an example), I don't get the
> expected behavior:

Use bash(1) (which supports <(command args) file handles) and try
this one-liner.

    $ printf "Content-Type: multipart/mixed; boundary = 
-\n\n---\nContent-Disposition: inline;\n filename = foo.txt\n\n-----\n" |
        postmap -m -h -q - pcre:<(printf '/^Content-Disposition:.*filename/ 
REJECT foo')

My output is:

    Content-Disposition: inline;
     filename = foo.txt REJECT foo

If you see something else, do post the details. Otherwise, your
test is still flawed, in that you're not testing with a valid MIME
message.

-- 
        Viktor.

Reply via email to