[PATCH] Add ~M pattern to match mime Content-Types.

Kevin J. McCarthy kevin at 8t8.us
Fri Apr 27 00:34:16 UTC 2018

On Thu, Apr 26, 2018 at 05:14:27PM -0700, Ammon Riley wrote:
> > The =b/=B/=h are explicity mentioned because of their IMAP behavior.
> I did copy the =b/=B.  I hadn't considered IMAP for this feature, as I'm
> not using it.  Since we have to parse the message to match content-type,
> how would this behave under IMAP?  Would it work on the server, or
> does it have to be local?  If it can work on the server, then perhaps I
> should distinguish that -- I can imagine an IMAP user might not want to
> download large PDF-containing messages while performing this limit.

It will download the message.  I'll have to check myself if there is
some way to do it server-side.

> Updated patch attached.

Your new patch was too fast. :-)  I realized I forgot to include one
other comment, below.  I have to run, but I'll take another closer look
at the revised patch later tonight.

> diff --git a/pattern.c b/pattern.c
> +static int match_content_type(const pattern_t* pat, BODY *b)
> +{
> +  char buffer[STRING];
> +  if (!b)
> +    return 0;
> +
> +  if (snprintf(buffer, STRING, "%s/%s", TYPE (b), b->subtype) >= STRING)
> +    buffer[STRING-1] = '\0';

snprintf (unlike strncpy) will always add the terminating null byte.

Kevin J. McCarthy
GPG Fingerprint: 8975 A9B3 3AA3 7910 385C  5308 ADEF 7684 8031 6BDA
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.mutt.org/pipermail/mutt-dev/attachments/20180426/2cc18d86/attachment.asc>

More information about the Mutt-dev mailing list