]> granicus.if.org Git - neomutt/commitdiff
forgotten-attachment: fix empty regex expression
authorRichard Russon <rich@flatcap.org>
Mon, 10 Oct 2016 08:51:05 +0000 (09:51 +0100)
committerRichard Russon <rich@flatcap.org>
Mon, 10 Oct 2016 09:10:16 +0000 (10:10 +0100)
The original regex was of the form "abc(|def)" to check for both "abc"
and "abcdef".  Unfortunately, the regex libraries on BSDs/MacOS don't
like this use of an empty sub-expression.

Expanding the regex to: "(abc|abcdef)" fixes the problem.

Fixes: neomutt/homebrew-neomutt#15
doc/manual.xml.head
doc/muttrc.forgotten-attachment
init.c
init.h
send.c

index 51b5c61cc01e50b61e301864e341109ab529cca9..7774cacd9915f5d9658696036f8ef6e1a3381150 100644 (file)
@@ -10142,7 +10142,7 @@ set pgp_encrypt_self = &quot;no&quot;
           <row>
             <entry><literal>attach_keyword</literal></entry>
             <entry>regular expression</entry>
-            <entry><literal>\\&lt;attach(|ed|ments?)\\&gt;</literal></entry>
+            <entry><literal>\\&lt;(attach|attached|attachments?)\\&gt;</literal></entry>
           </row>
           <row>
             <entry><literal>abort_noattach</literal></entry>
index 270118b7ebe6b41065ae1907fd862720d6f7ea55..daadcf91d9012db234d9ec5022a0aa71ef63a523 100644 (file)
@@ -16,7 +16,7 @@ set abort_noattach = no
 # Search for the following regular expression in the body of the email
 
 # English: attach, attached, attachment, attachments
-set attach_keyword = "\\<attach(|ed|ments?)\\>"
+set attach_keyword = "\\<(attach|attached|attachments?)\\>"
 
 # Nederlands:
 # set attach_keyword = "\\<(bijvoegen|bijgevoegd|bijlage|bijlagen)\\>"
diff --git a/init.c b/init.c
index 95e2a7d2e243d8e1be6b4bd637f01450e40aa093..b26fea1e04d89e616b2fcf0c97c53de840f7b0eb 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1704,6 +1704,7 @@ static void mutt_restore_default (struct option_t *p)
 
        if (p->init)
        {
+         int retval;
          char *s = (char *) p->init;
 
          pp->rx = safe_calloc (1, sizeof (regex_t));
@@ -1715,10 +1716,15 @@ static void mutt_restore_default (struct option_t *p)
            s++;
            pp->not = 1;
          }
-         if (REGCOMP (pp->rx, s, flags) != 0)
+         retval = REGCOMP (pp->rx, s, flags);
+         if (retval != 0)
          {
+           char msgbuf[STRING];
+           regerror (retval, pp->rx, msgbuf, sizeof (msgbuf));
            fprintf (stderr, _("mutt_restore_default(%s): error in regexp: %s\n"),
                     p->option, pp->pattern);
+           fprintf (stderr, "%s\n", msgbuf);
+           mutt_sleep (0);
            FREE (&pp->pattern);
            FREE (&pp->rx);
          }
diff --git a/init.h b/init.h
index 0c76cd0e5241b928046f3269d0d0f43976acd4bb..461bc6cd5b962f7033cbef7d5fe82f48d481d139 100644 (file)
--- a/init.h
+++ b/init.h
@@ -267,7 +267,7 @@ struct option_t MuttVars[] = {
   ** .pp
   ** For an explanation of ``soft-fill'', see the $$index_format documentation.
   */
-  { "attach_keyword",  DT_RX,  R_NONE, UL &AttachKeyword, UL "\\<attach(|ed|ments?)\\>" },
+  { "attach_keyword",  DT_RX,  R_NONE, UL &AttachKeyword, UL "\\<(attach|attached|attachments?)\\>" },
   /*
   ** .pp
   ** If $abort_noattach is not set to no, then the body of the message
diff --git a/send.c b/send.c
index e5a7bf31ecf3bb5149279cbb8a2b1dbacdb1d0d7..7f5d1371adeda04277109f86b8939eaef70a0cca 100644 (file)
--- a/send.c
+++ b/send.c
@@ -1902,7 +1902,7 @@ main_loop:
     /* if the abort is automatic, print an error message */
     if (quadoption (OPT_ATTACH) == MUTT_YES)
     {
-      mutt_error _("Message contains text matching \"attach_keyword\". Not sending.");
+      mutt_error _("Message contains text matching \"$attach_keyword\". Not sending.");
     }
     goto main_loop;
   }