nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] pick(1) decode RFC-2047 headers?

2012-11-24 16:47:48
Ken wrote:

Hrm.  As I read it this will also try to decode the body of a
message, right?  Not sure if that's a good idea.  Fixing that might
require some more surgery to pick, though.

pick quits once it reaches the body, except with -search,
so not a problem:

  if (body && n->n_header)
      return 0;

With -search, it will try to decode and fail, but I don't
think that's worth inhibiting.  It would be nice to decode
message parts, some day.

decode_rfc2047() returns zero if it failed to decode anything,
so we can rely on that instead of trying to determine in advance
whether to call it.

David


diff --git a/uip/picksbr.c b/uip/picksbr.c
index 4895b23..b3fac9c 100644
--- a/uip/picksbr.c
+++ b/uip/picksbr.c
@@ -78,6 +78,7 @@ static struct swit parswit[] = {
 
 
 static char linebuf[LBSIZE + 1];
+static char decoded_linebuf[LBSIZE + 1];
 
 /* the magic array for case-independence */
 static unsigned char cc[] = {
@@ -714,6 +715,11 @@ plist
        p1 = linebuf;
        p2 = n->n_expbuf;
 
+       /* Attempt to decode as a MIME header. */
+       if (decode_rfc2047 (linebuf, decoded_linebuf, sizeof decoded_linebuf)) {
+           p1 = decoded_linebuf;
+       }

_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>