Skip to content

Commit

Permalink
forgotten-attachment: fix empty regex expression
Browse files Browse the repository at this point in the history
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
  • Loading branch information
flatcap committed Oct 10, 2016
1 parent a03e45b commit 3bc69ca
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion doc/manual.xml.head
Expand Up @@ -10142,7 +10142,7 @@ set pgp_encrypt_self = "no"
<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>
Expand Down
2 changes: 1 addition & 1 deletion doc/muttrc.forgotten-attachment
Expand Up @@ -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)\\>"
Expand Down
8 changes: 7 additions & 1 deletion init.c
Expand Up @@ -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));
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion init.h
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion send.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit 3bc69ca

Please sign in to comment.