]> granicus.if.org Git - neomutt/commitdiff
Disable ~X when message scoring. (closes #3861)
authorKevin McCarthy <kevin@8t8.us>
Sat, 3 Sep 2016 02:32:39 +0000 (19:32 -0700)
committerKevin McCarthy <kevin@8t8.us>
Sat, 3 Sep 2016 02:32:39 +0000 (19:32 -0700)
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.

doc/manual.xml.head
pattern.c

index ac22afa76de692794da845948f516203ddf3b7f5..4b7d37d866e3326f41b04d19b9399ca374fe18bc 100644 (file)
@@ -3837,8 +3837,8 @@ a message's score if <emphasis>pattern</emphasis> matches it.
 <emphasis>pattern</emphasis> is a string in the format described in the
 <link linkend="patterns">patterns</link> section (note: For efficiency
 reasons, patterns which scan information not available in the index,
-such as <literal>~b</literal>, <literal>~B</literal> or
-<literal>~h</literal>, may not be used).  <emphasis>value</emphasis> is
+such as <literal>~b</literal>, <literal>~B</literal>, <literal>~h</literal>,
+or <literal>~X</literal> may not be used).  <emphasis>value</emphasis> is
 a positive or negative integer.  A message's final score is the sum
 total of all matching <command>score</command> entries.  However, you
 may optionally prefix <emphasis>value</emphasis> with an equal sign
index 85d38b5f44f57053c295becb6d9aead903a38c0e..1248e14efeab364de11c2bb6ed6a036eca948590 100644 (file)
--- 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 ||