~kevin8t8/mutt

2311519a495da7e2cbb4fd5829e466a8610541c3 — Kevin McCarthy 9 days ago e53ae9e
Disable hook "command" argument expansion of config variables.

From my email to mutt-dev:

  I've been thinking about this a *lot* more, and digging into past
  commits.  It looks like the escaping has pretty consistently been
  intended for value completion and queries.  See commits 3c00eb7a and
  032dcbeb.

  I don't believe the escaping is useful for variable expansion as
  part of mutt_extract_token() - even for the hook "command" argument
  case.  The escaping is targeted only for an expression surrounded by
  double quotes (as is generated by completion and queries).  It
  doesn't escape single quotes or spaces, for instance.

Thanks also to Oswald Buddenhagen and Cameron Simpson for their
feedback.
2 files changed, 11 insertions(+), 3 deletions(-)

M hook.c
M init.c
M hook.c => hook.c +8 -3
@@ 75,11 75,16 @@ int mutt_parse_hook (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER 
    goto cleanup;
  }

  /* These hook types have a command parameter which is run through
   * mutt_parse_rc_line() a second time upon hook execution. */
  /* These hook types have a "command" parameter.
   * It's useful be able include spaces without having to quote it.
   *
   * Note: MUTT_TOKEN_ESC_VARS was briefly added to the flag for
   * backwards compatibilty, but after research and discussion
   * was removed.
   */
  if (data & (MUTT_FOLDERHOOK | MUTT_SENDHOOK | MUTT_SEND2HOOK |
              MUTT_ACCOUNTHOOK | MUTT_REPLYHOOK | MUTT_MESSAGEHOOK))
    token_flags = MUTT_TOKEN_SPACE | MUTT_TOKEN_ESC_VARS;
    token_flags = MUTT_TOKEN_SPACE;

  mutt_extract_token (command, s, token_flags);


M init.c => init.c +3 -0
@@ 313,6 313,9 @@ int mutt_extract_token (BUFFER *dest, BUFFER *tok, int flags)

          if (var_to_string (idx, val))
          {
            /* This flag is not used.  I'm keeping the code for the next
             * release cycle in case it needs to be reenabled for hooks.
             */
            if (flags & MUTT_TOKEN_ESC_VARS)
            {
              BUFFER *escval = mutt_buffer_pool_get ();