As part of the implementation of nested-if[1], we translate old-style
conditional expandos into nested-if expandos. However, this translation
did not account for the metacharacters that need to be escaped in
nested-if expandos that are valid in old-style expandos (in particular
"<" and ">"). Correct this by escaping the relevant metacharacters.
With this patch, it is now possible to do something like
:set status_format=" %rMail%r >%?u? +%u >?"
Without causing an ">" to be included if %u is 0 (which used to be the
case).
[1]: https://www.neomutt.org/feature/nested-if
Fixes #1001
<para>Richard Russon
<email>rich@flatcap.org</email></para>
</listitem>
+ <listitem>
+ <para>Aleksa Sarai
+ <email>cyphar@cyphar.com</email></para>
+ </listitem>
</itemizedlist>
</sect2>
</sect1>
/* %?x?y&z? to %<x?y&z> where y and z are nestable */
char *p = (char *) src;
*p = '<';
+ /* skip over "x" */
for (; *p && *p != '?'; p++)
;
/* nothing */
if (*p == '?')
- {
p++;
- }
+ /* fix up the "y&z" section */
for (; *p && *p != '?'; p++)
- ;
- /* nothing */
- if (*p == '?')
{
- *p = '>';
+ /* escape '<' and '>' to work inside nested-if */
+ if ((*p == '<') || (*p == '>'))
+ {
+ memmove(p + 2, p, mutt_str_strlen(p) + 1);
+ *p++ = '\\';
+ *p++ = '\\';
+ }
}
+ if (*p == '?')
+ *p = '>';
}
if (*src == '<')