From: Kevin McCarthy Date: Sat, 3 Sep 2016 02:32:39 +0000 (-0700) Subject: Disable ~X when message scoring. (closes #3861) X-Git-Tag: neomutt-20160910~12^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f73fef77159498abc152f0554080a4bec18987fa;p=neomutt Disable ~X when message scoring. (closes #3861) mutt_score_message() purposely passes a NULL context to mutt_pattern_exec(). The idea was to block slow patterns, and the scoring documentation notes this by saying: "For efficiency reasons, patterns which scan information not available in the index, such as ~b, ~B or ~h, may not be used" ~X needs the context to parse the messages (during message scoring at least), and thus isn't suitable for message scoring either. Block ~X from being used when the context is NULL. Add ~X to the list of patterns noted as unusable in the message scoring documentation. --- diff --git a/doc/manual.xml.head b/doc/manual.xml.head index ac22afa76..4b7d37d86 100644 --- a/doc/manual.xml.head +++ b/doc/manual.xml.head @@ -3837,8 +3837,8 @@ a message's score if pattern matches it. pattern is a string in the format described in the patterns section (note: For efficiency reasons, patterns which scan information not available in the index, -such as ~b, ~B or -~h, may not be used). value is +such as ~b, ~B, ~h, +or ~X may not be used). value is a positive or negative integer. A message's final score is the sum total of all matching score entries. However, you may optionally prefix value with an equal sign diff --git a/pattern.c b/pattern.c index 85d38b5f4..1248e14ef 100644 --- a/pattern.c +++ b/pattern.c @@ -1142,6 +1142,7 @@ mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags, CONTEXT *ctx, /* * ctx can be NULL in certain cases, such as when replying to a message from the attachment menu and * the user has a reply-hook using "~h" (bug #2190). + * This is also the case when message scoring. */ if (!ctx) return 0; @@ -1215,6 +1216,8 @@ mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags, CONTEXT *ctx, case MUTT_DUPLICATED: return (pat->not ^ (h->thread && h->thread->duplicate_thread)); case MUTT_MIMEATTACH: + if (!ctx) + return 0; { int count = mutt_count_body_parts (ctx, h); return (pat->not ^ (count >= pat->min && (pat->max == MUTT_MAXRANGE ||