summaryrefslogtreecommitdiffstats
path: root/handler.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2021-02-04 18:02:06 -0800
committerKevin McCarthy <kevin@8t8.us>2021-02-05 13:37:58 -0800
commit18c29a84f2ae4679f8c9a7ac032c9b8b680419af (patch)
treeb05b36873c0784d35df58213bd42294141c24a57 /handler.c
parent1a9fea6f9aa506cd2ac8222cee05889b775f8613 (diff)
Filter ANSI sequences when forwarding too.
Add a MUTT_CM_FORWARDING flag to correspond with the MUTT_CM_REPLYING flag. Check those to turn on ANSI filtering. In order to guard against other accidental prefix setting without one of those flags, also check s->prefix to enable ANSI filtering (and prefix printing) too. Add missing MUTT_CM_REPLYING flags to the recvcmd.c reply functions. While updating the recvcmd.c reply code, I noticed CH_REORDER wasn't enabled with OPTWEED, like in the send.c code (and everywhere else), so add the missing flag.
Diffstat (limited to 'handler.c')
-rw-r--r--handler.c57
1 files changed, 27 insertions, 30 deletions
diff --git a/handler.c b/handler.c
index 31b21878..35477e2c 100644
--- a/handler.c
+++ b/handler.c
@@ -1378,55 +1378,52 @@ static int autoview_handler (BODY *a, STATE *s)
goto bail;
}
- if (s->prefix)
+ /* Note: only replying and forwarding use s->prefix, but just to
+ * be safe, keep an explicit check for s->prefix too. */
+ if ((s->flags & (MUTT_REPLYING | MUTT_FORWARDING)) || s->prefix)
{
- /* Remove ansi and formatting from autoview output in replies only.
+ /* Remove ansi and formatting from autoview output.
* The user may want to see the formatting in the pager, but it
- * shouldn't be in their quoted reply text too.
+ * shouldn't be in their quoted reply or inline forward text too.
*/
BUFFER *stripped = mutt_buffer_pool_get ();
while (fgets (buffer, sizeof(buffer), fpout) != NULL)
{
mutt_buffer_strip_formatting (stripped, buffer, 0);
- state_puts (s->prefix, s);
+ if (s->prefix)
+ state_puts (s->prefix, s);
state_puts (mutt_b2s (stripped), s);
}
mutt_buffer_pool_release (&stripped);
+ }
+ else
+ {
+ mutt_copy_stream (fpout, s->fpout);
+ }
- /* check for data on stderr */
- if (fgets (buffer, sizeof(buffer), fperr))
+ /* Check for stderr messages */
+ if (fgets (buffer, sizeof(buffer), fperr))
+ {
+ if (s->flags & MUTT_DISPLAY)
{
- if (s->flags & MUTT_DISPLAY)
- {
- state_mark_attach (s);
- state_printf (s, _("[-- Autoview stderr of %s --]\n"), mutt_b2s (command));
- }
+ state_mark_attach (s);
+ state_printf (s, _("[-- Autoview stderr of %s --]\n"), mutt_b2s (command));
+ }
- state_puts (s->prefix, s);
- state_puts (buffer, s);
+ if (s->prefix)
+ state_puts (s->prefix, s);
+ state_puts (buffer, s);
+
+ if (s->prefix)
+ {
while (fgets (buffer, sizeof(buffer), fperr) != NULL)
{
state_puts (s->prefix, s);
state_puts (buffer, s);
}
}
- }
- else
- {
- mutt_copy_stream (fpout, s->fpout);
- /* Check for stderr messages */
- if (fgets (buffer, sizeof(buffer), fperr))
- {
- if (s->flags & MUTT_DISPLAY)
- {
- state_mark_attach (s);
- state_printf (s, _("[-- Autoview stderr of %s --]\n"),
- mutt_b2s (command));
- }
-
- state_puts (buffer, s);
- mutt_copy_stream (fperr, s->fpout);
- }
+ else
+ mutt_copy_stream (fperr, s->fpout);
}
bail: