[Nmh-workers] pick(1) decode RFC-2047 headers?
Ralph pointed out earlier that with the proliferation of RFC 2047-encoded headers, pick is much less useful. I'm wondering ... would it make sense to simply have pick run the RFC 2047 decoder on headers before matching them? As far as I can tell we can decode all headers except for Received: headers. Thoughts? --Ken ___ Nmh-workers mailing list Nmh-workers@nongnu.org https://lists.nongnu.org/mailman/listinfo/nmh-workers
Re: [Nmh-workers] pick(1) decode RFC-2047 headers?
+1. Anything that works in terms of lines is outdated at this point. Ken Hornstein k...@pobox.com wrote: Ralph pointed out earlier that with the proliferation of RFC 2047-encoded headers, pick is much less useful. I'm wondering ... would it make sense to simply have pick run the RFC 2047 decoder on headers before matching them? As far as I can tell we can decode all headers except for Received: headers. Thoughts? --Ken ___ Nmh-workers mailing list Nmh-workers@nongnu.org https://lists.nongnu.org/mailman/listinfo/nmh-workers -- Sent from my Android phone with K-9 Mail. Please excuse my brevity.___ Nmh-workers mailing list Nmh-workers@nongnu.org https://lists.nongnu.org/mailman/listinfo/nmh-workers
Re: [Nmh-workers] pick(1) decode RFC-2047 headers?
+1 too. Anything that works in terms of lines is outdated at this point. Eek! (Squealing like a mouse in the inside.) steve -- On Sat, Nov 24 2012 at 9:40am PST, P Vixie p...@redbarn.org wrote: +1. Anything that works in terms of lines is outdated at this point. Ken Hornstein k...@pobox.com wrote: Ralph pointed out earlier that with the proliferation of RFC 2047-encoded headers, pick is much less useful. I'm wondering ... would it make sense to simply have pick run the RFC 2047 decoder on headers before matching them? As far as I can tell we can decode all headers except for Received: headers. Thoughts? --Ken ___ Nmh-workers mailing list Nmh-workers@nongnu.org https://lists.nongnu.org/mailman/listinfo/nmh-workers -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. ___ Nmh-workers mailing list Nmh-workers@nongnu.org https://lists.nongnu.org/mailman/listinfo/nmh-workers ___ Nmh-workers mailing list Nmh-workers@nongnu.org https://lists.nongnu.org/mailman/listinfo/nmh-workers
Re: [Nmh-workers] pick(1) decode RFC-2047 headers?
Ken Hornstein k...@pobox.com writes: Ralph pointed out earlier that with the proliferation of RFC 2047-encoded headers, pick is much less useful. I'm wondering ... would it make sense to simply have pick run the RFC 2047 decoder on headers before matching them? As far as I can tell we can decode all headers except for Received: headers. Thoughts? Header fields should be RFC 2047-decoded before any MH operation that considers the content of the message, including pick, shouldn't they? -- Bill Wohler woh...@newt.com aka bill.woh...@nasa.gov http://www.newt.com/wohler/ GnuPG ID:610BD9AD ___ Nmh-workers mailing list Nmh-workers@nongnu.org https://lists.nongnu.org/mailman/listinfo/nmh-workers
Re: [Nmh-workers] pick(1) decode RFC-2047 headers?
Ken wrote: I'm wondering ... would it make sense to simply have pick run the RFC 2047 decoder on headers before matching them? As far as I can tell we can decode all headers except for Received: headers. Thoughts? Definitely. Though I'm not sure we want to try to decode a non-MIME header. I tried the quick proof of concept below and it worked, though it might not be the best way to do things. I had originally wanted to use fmt_compile()/fmt_scan(), but quickly got over that :-/ Unfortunately, there isn't one place we could do this for all of the programs. Even within pick, it uses m_getfld() to read dates for -before/-after but fgets() to read header fields for search. David diff --git a/uip/picksbr.c b/uip/picksbr.c index 4895b23..e38a1d8 100644 --- a/uip/picksbr.c +++ b/uip/picksbr.c @@ -714,6 +714,15 @@ plist p1 = linebuf; p2 = n-n_expbuf; + if (strstr (p1, =?)strstr (p1, ?=)) { + /* Proof of concept: decode a MIME header. */ + char *decoded = mh_xmalloc (sizeof linebuf); + + decode_rfc2047 (p1, decoded, sizeof linebuf); + strncpy (linebuf, decoded, sizeof linebuf); + free (decoded); + } ___ Nmh-workers mailing list Nmh-workers@nongnu.org https://lists.nongnu.org/mailman/listinfo/nmh-workers
Re: [Nmh-workers] pick(1) decode RFC-2047 headers?
On 24 November 2012 at 9:52, Bill Wohler woh...@newt.com wrote: Ken Hornstein k...@pobox.com writes: Ralph pointed out earlier that with the proliferation of RFC 2047-encoded headers, pick is much less useful. I'm wondering ... would it make sense to simply have pick run the RFC 2047 decoder on headers before matching them? As far as I can tell we can decode all headers except for Received: headers. Thoughts? Header fields should be RFC 2047-decoded before any MH operation that considers the content of the message, including pick, shouldn't they? One more here concurring about the headers. This begs the question about -search pattern, where pattern is what the reader sees. But, pattern could also be obfuscated by quoted-printable or html message content. FWIW, I scripted a multi-folder pick, which I call pickf. If pick is going to be altered, then being able to specify multiple folders would be a nice feature addition, at least for me. I guess I just suggested a boat load of work. Sorry 'bout that. Cheerio -- Kevin ___ Nmh-workers mailing list Nmh-workers@nongnu.org https://lists.nongnu.org/mailman/listinfo/nmh-workers
Re: [Nmh-workers] pick(1) decode RFC-2047 headers?
FWIW, I scripted a multi-folder pick, which I call pickf. If pick is going to be altered, then being able to specify multiple folders would be a nice feature addition, at least for me. I guess I just suggested a boat load of work. Sorry 'bout that. That's fine ... I look forward to your patches! :-) I understand about -search, but that's hard and requires some rethinking. For example, do you really want to be searching application/octet-stream? Okay, people might ... but in my mind that really says we need to specify certain MIME content types that we want to be searching. --Ken ___ Nmh-workers mailing list Nmh-workers@nongnu.org https://lists.nongnu.org/mailman/listinfo/nmh-workers
Re: [Nmh-workers] pick(1) decode RFC-2047 headers?
Header fields should be RFC 2047-decoded before any MH operation that considers the content of the message, including pick, shouldn't they? Is that a rhetorical question? :-) In a perfect world, yes, that would happen. But RFC 2047 support wasn't integral to MH; it got grafted on after MH development stopped, but before we moved nmh to savannah. It was actually only implemented in the format engine with the %(decode) function. Besides the issue of dealing with decoded strings internally, there are other problems as well. For example, we don't have a RFC 2047 encoder, so if we (for example) decode a subject line we have no way of encoding it properly. So right now anything that wants to handle decoded headers has to take care of that itself. Everything so far that has done that uses the format engine. --Ken ___ Nmh-workers mailing list Nmh-workers@nongnu.org https://lists.nongnu.org/mailman/listinfo/nmh-workers
Re: [Nmh-workers] pick(1) decode RFC-2047 headers?
I tried the quick proof of concept below and it worked, though it might not be the best way to do things. I had originally wanted to use fmt_compile()/fmt_scan(), but quickly got over that :-/ 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. --Ken ___ Nmh-workers mailing list Nmh-workers@nongnu.org https://lists.nongnu.org/mailman/listinfo/nmh-workers
Re: [Nmh-workers] pick(1) decode RFC-2047 headers?
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@nongnu.org https://lists.nongnu.org/mailman/listinfo/nmh-workers
Re: [Nmh-workers] pick(1) decode RFC-2047 headers?
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. Yeah, but we wouldn't be decoding them with decode_rfc2047(), that's my point. Couldn't we just do + if (body == 0 decode_rfc2047 (linebuf, decoded_linebuf, sizeof decoded_linebuf)) { ? --Ken ___ Nmh-workers mailing list Nmh-workers@nongnu.org https://lists.nongnu.org/mailman/listinfo/nmh-workers
Re: [Nmh-workers] pick(1) decode RFC-2047 headers?
Ken wrote: Couldn't we just do +if (body == 0 decode_rfc2047 (linebuf, decoded_linebuf, sizeof decoded_linebuf)) { Yup, that'll work. David ___ Nmh-workers mailing list Nmh-workers@nongnu.org https://lists.nongnu.org/mailman/listinfo/nmh-workers
Re: [Nmh-workers] pick(1) decode RFC-2047 headers?
Ken wrote: Couldn't we just do +if (body == 0 decode_rfc2047 (linebuf, decoded_linebuf, sizeof decoded_linebuf)) { Yup, that'll work. Except for the last header. body gets set before breaking out of the loop. David ___ Nmh-workers mailing list Nmh-workers@nongnu.org https://lists.nongnu.org/mailman/listinfo/nmh-workers
Re: [Nmh-workers] pick(1) decode RFC-2047 headers?
Ken wrote: Couldn't we just do +if (body == 0 decode_rfc2047 (linebuf, decoded_linebuf, sizeof decoded_linebuf)) { Yup, that'll work. Except for the last header. body gets set before breaking out of the loop. (body == 0 || lf 0) takes care of that. David ___ Nmh-workers mailing list Nmh-workers@nongnu.org https://lists.nongnu.org/mailman/listinfo/nmh-workers
Re: [Nmh-workers] pick(1) decode RFC-2047 headers?
Except for the last header. body gets set before breaking out of the loop. (body == 0 || lf 0) takes care of that. ... I'll take your word on it, because I've squinted at that code for a little bit now and I still can't figure out what it's doing :-/ --Ken ___ Nmh-workers mailing list Nmh-workers@nongnu.org https://lists.nongnu.org/mailman/listinfo/nmh-workers