From 3bc69ca25077b171f1ae9beee484629c5b5c6482 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Mon, 10 Oct 2016 09:51:05 +0100 Subject: [PATCH] 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 --- doc/manual.xml.head | 2 +- doc/muttrc.forgotten-attachment | 2 +- init.c | 8 +++++++- init.h | 2 +- send.c | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/doc/manual.xml.head b/doc/manual.xml.head index 51b5c61cc01..7774cacd991 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 270118b7ebe..daadcf91d90 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 95e2a7d2e24..b26fea1e04d 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 0c76cd0e524..461bc6cd5b9 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 e5a7bf31ecf..7f5d1371ade 100644 --- a/send.c +++ b/send.c @@ -1902,7 +1902,7 @@ ci_send_message (int flags, /* send mode */ /* 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; }