From: Richard Russon Date: Mon, 10 Oct 2016 08:51:05 +0000 (+0100) Subject: forgotten-attachment: fix empty regex expression X-Git-Tag: neomutt-20161014~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3bc69ca25077b171f1ae9beee484629c5b5c6482;p=neomutt forgotten-attachment: fix empty regex expression 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 --- diff --git a/doc/manual.xml.head b/doc/manual.xml.head index 51b5c61cc..7774cacd9 100644 --- a/doc/manual.xml.head +++ b/doc/manual.xml.head @@ -10142,7 +10142,7 @@ set pgp_encrypt_self = "no" attach_keyword regular expression - \\<attach(|ed|ments?)\\> + \\<(attach|attached|attachments?)\\> abort_noattach diff --git a/doc/muttrc.forgotten-attachment b/doc/muttrc.forgotten-attachment index 270118b7e..daadcf91d 100644 --- a/doc/muttrc.forgotten-attachment +++ b/doc/muttrc.forgotten-attachment @@ -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 = "\\" +set attach_keyword = "\\<(attach|attached|attachments?)\\>" # Nederlands: # set attach_keyword = "\\<(bijvoegen|bijgevoegd|bijlage|bijlagen)\\>" diff --git a/init.c b/init.c index 95e2a7d2e..b26fea1e0 100644 --- 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 0c76cd0e5..461bc6cd5 100644 --- 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_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 e5a7bf31e..7f5d1371a 100644 --- 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; }