procmail
[Top] [All Lists]

Re: Trouble with pm-jamime-decode.rc,v 1.2 1998/03/30 09:49:09

2000-02-15 09:25:25
On Tue, 15 Feb 2000 16:36:35 +0100 (MET), Ralph SOBEK <sobek(_at_)irit(_dot_)fr>
wrote:
     I found that pm-jamime-decode.rc does not decode
quoted-printable if it is only in the body of the message, In this
case, in the header we only get something of the sort:

Your diagnostic is not quite correct. I believe the explanation is to
be found somewhere in the module's documentation, where Jari explains
that this is a "quick and dirty" hack which only works for certain
cases.

#       This includerc supposes that the header has MIME header
#       Content-Type: text/plain and performs qp or base64 decoding
#       on the whole message. Note, that if you receive messages that
#       have many mime attachements, then this recipe is not suitable
#       for it.

That's basically your explanation. Handling of messages with more than
a single inline body part is beyond the scope of what this module will
handle.

As a short example, the following two pseudo-messages will basically
display identically (except for the Subject :-), but the latter is too
hard for the simple MIME module.

    Subject: Example one
    Mime-Version: 1.0
    Content-Type: text/plain; charset=us-ascii
    Content-Transfer-Encoding: quoted-printable

    Hi mom!=


Notice how that is basically a normal RFC822 message with some funny =
escapes in the body, and a couple of "extra" headers. The MIME is
"inlined" in an RFC822 without much visible extra structure.

    Subject: Example two
    Mime-Version: 1.0
    Content-Type: multipart/mixed; boundary="free_software_rulez"

    --free_software_rulez
    Content-Type: text/plain; charset=us-ascii
    Content-Transfer-Encoding: quoted-printable

    Hi mom!=


    --free_sofrware_rulez--

By contrast, this one has an additional structure which is entirely in
the body, in RFC822 terms. As far as MIME is concerned, the headers
are split up in the RFC822 headers and a hierarchy of body parts (in
this case, exactly one) in the RFC822 body. On the other hand, RFC822
(and Procmail) only sees the body as a lump of text, with no real
structure in it.

It is an unfortunate fact that there are not many good command-line
tools for manipulating messages like the second example above easily.
Probably coping with this shouldn't be Procmail's business anyway,
although it would be nice to have +some+ support for handling
hierarchical data.

There are also some minor things to note in the module:

:0
*$ $JA_MIME_DECODE_REGEXP
{
    :0 fbw
    * ^Content-Transfer-Encoding: *quoted-printable
    | $MIME_BIN_QP

        :0 Afhw
        | $FORMAIL -I "Content-Transfer-Encoding: 8bit"

    :0 fbw
    * ^Content-Transfer-Encoding: *base64
    | $MIME_BIN_64

        :0 Afhw
        | $FORMAIL -I "Content-Transfer-Encoding: 8bit"
}

This is incorrect. You can't know that the decoded message will be
suitable for Content-Transfer-Encoding: 8bit. In fact, decoded base64
is somewhat likely to require C-T-E: binary instead.

:0 EB
*$ $JA_MIME_DECODE_REGEXP
{
    :0 fbw
    * ^Content-Transfer-Encoding: *quoted-printable
    | $MIME_BIN_QP

        :0 Afhw
        | $FORMAIL -I "Content-Transfer-Encoding: 8bit"

This is the part you added yourself, yes? This will not modify your
example message at all, because the inner condition still requires the
+header+ to have a Content-Transfer-Encoding: quoted-printable line.

There is a Perl MIME module which will allow you to manipulate MIME
body parts rather elegantly. I haven't tried it for anything real so I
can't comment on its stability, but the documentation certainly makes
it look nice. <http://www.perl.com/CPAN-local/authors/Eryq/>, look for
MIME-tools.

Actually, my Debian setup comes with a thing called mimedecode. I
haven't actually tried it but the copyright file has a pointer to
<ftp://ftp.dde.dk/pub/mimedecode.c>

Hope this helps,

/* era */

-- 
 Too much to say to fit into this .signature anyway: <http://www.iki.fi/era/>
  Fight spam in Europe: <http://www.euro.cauce.org/> * Sign the EU petition