mutt_buffer_init (&pattern);
mutt_buffer_init (&command);
- if (~data & MUTT_GLOBALHOOK)
+ if (~data & MUTT_GLOBALHOOK) /* NOT a global hook */
{
if (*s->dptr == '!')
{
goto error;
}
}
- else
- {
- mutt_extract_token (&pattern, s, 0);
- }
mutt_extract_token (&command, s, (data & (MUTT_FOLDERHOOK | MUTT_SENDHOOK | MUTT_SEND2HOOK | MUTT_ACCOUNTHOOK | MUTT_REPLYHOOK)) ? MUTT_TOKEN_SPACE : 0);
}
}
#endif
- else if (DefaultHook && !(data & (MUTT_CHARSETHOOK | MUTT_ICONVHOOK | MUTT_ACCOUNTHOOK))
+ else if (DefaultHook && (~data & MUTT_GLOBALHOOK) &&
+ !(data & (MUTT_CHARSETHOOK | MUTT_ICONVHOOK | MUTT_ACCOUNTHOOK))
&& (!WithCrypto || !(data & MUTT_CRYPTHOOK))
)
{
/* check to make sure that a matching hook doesn't already exist */
for (ptr = Hooks; ptr; ptr = ptr->next)
{
- if (ptr->type == data &&
+ if (data & MUTT_GLOBALHOOK)
+ {
+ /* Ignore duplicate global hooks */
+ if (mutt_strcmp (ptr->command, command.data) == 0)
+ {
+ FREE (&command.data);
+ return 0;
+ }
+ }
+ else if (ptr->type == data &&
ptr->rx.not == not &&
!mutt_strcmp (pattern.data, ptr->rx.pattern))
{
err)) == NULL)
goto error;
}
- else
+ else if (~data & MUTT_GLOBALHOOK) /* NOT a global hook */
{
/* Hooks not allowing full patterns: Check syntax of regexp */
rx = safe_malloc (sizeof (regex_t));
return 0;
error:
- FREE (&pattern.data);
+ if (~data & MUTT_GLOBALHOOK) /* NOT a global hook */
+ FREE (&pattern.data);
FREE (&command.data);
return (-1);
}