WHERE CONTEXT *Context;
WHERE char Errorbuf[STRING];
+WHERE char AttachmentMarker[STRING];
#if defined(DL_STANDALONE) && defined(USE_DOTLOCK)
WHERE char *MuttDotlock;
else if (s->flags & M_DISPLAY)
{
/* didn't find anything that we could display! */
+ state_mark_attach (s);
state_puts(_("[-- Error: Could not display any parts of Multipart/Alternative! --]\n"), s);
}
}
{
if (s->flags & M_DISPLAY)
{
+ state_mark_attach (s);
state_printf (s, _("[-- Attachment #%d"), count);
if (p->description || p->filename || p->form_name)
{
mutt_pretty_size (length, sizeof (length), p->length);
+ state_mark_attach (s);
state_printf (s, _("[-- Type: %s/%s, Encoding: %s, Size: %s --]\n"),
TYPE (p), p->subtype, ENCODING (p->encoding), length);
if (!option (OPTWEED))
if (s->flags & M_DISPLAY)
{
+ state_mark_attach (s);
state_printf (s, _("[-- Autoview using %s --]\n"), command);
mutt_message(_("Invoking autoview command: %s"),command);
}
{
mutt_perror _("Can't create filter");
if (s->flags & M_DISPLAY)
+ {
+ state_mark_attach (s);
state_printf (s, _("[-- Can't run %s. --]\n"), command);
+ }
goto bail;
}
/* check for data on stderr */
if (fgets (buffer, sizeof(buffer), fperr))
{
- if (s->flags & M_DISPLAY)
+ if (s->flags & M_DISPLAY)
+ {
+ state_mark_attach (s);
state_printf (s, _("[-- Autoview stderr of %s --]\n"), command);
+ }
state_puts (s->prefix, s);
state_puts (buffer, s);
if (fgets (buffer, sizeof(buffer), fperr))
{
if (s->flags & M_DISPLAY)
+ {
+ state_mark_attach (s);
state_printf (s, _("[-- Autoview stderr of %s --]\n"),
command);
+ }
state_puts (buffer, s);
mutt_copy_stream (fperr, s->fpout);
if (!access_type)
{
if (s->flags & M_DISPLAY)
+ {
+ state_mark_attach (s);
state_puts (_("[-- Error: message/external-body has no access-type parameter --]\n"), s);
+ }
return;
}
{
char *length;
char pretty_size[10];
-
+
+ state_mark_attach (s);
state_printf (s, _("[-- This %s/%s attachment "),
TYPE(b->parts), b->parts->subtype);
length = mutt_get_parameter ("length", b->parameter);
state_puts (_("has been deleted --]\n"), s);
if (expire != -1)
+ {
+ state_mark_attach (s);
state_printf (s, _("[-- on %s --]\n"), expiration);
+ }
if (b->parts->filename)
+ {
+ state_mark_attach (s);
state_printf (s, _("[-- name: %s --]\n"), b->parts->filename);
+ }
mutt_copy_hdr (s->fpin, s->fpout, ftell (s->fpin), b->parts->offset,
(option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) |
{
if (s->flags & M_DISPLAY)
{
- state_printf (s, _("[-- This %s/%s attachment is not included, --]\n"
- "[-- and the indicated external source has --]\n"
- "[-- expired. --]\n"),
+ state_mark_attach (s);
+ state_printf (s, _("[-- This %s/%s attachment is not included, --]\n"),
TYPE(b->parts), b->parts->subtype);
+ state_attach_puts (_("[-- and the indicated external source has --]\n"), s);
+ state_attach_puts (_("[-- expired. --]\n"), s);
+
mutt_copy_hdr(s->fpin, s->fpout, ftell (s->fpin), b->parts->offset,
(option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) |
CH_DECODE, NULL);
{
if (s->flags & M_DISPLAY)
{
+ state_mark_attach (s);
state_printf (s,
- _("[-- This %s/%s attachment is not included, --]\n"
- "[-- and the indicated access-type %s is unsupported --]\n"),
- TYPE(b->parts), b->parts->subtype, access_type);
+ _("[-- This %s/%s attachment is not included, --]\n"),
+ TYPE (b->parts), b->parts->subtype);
+ state_mark_attach (s);
+ state_printf (s,
+ _("[-- and the indicated access-type %s is unsupported --]\n"),
+ access_type);
mutt_copy_hdr (s->fpin, s->fpout, ftell (s->fpin), b->parts->offset,
(option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) |
CH_DECODE , NULL);
}
else if (s->flags & M_DISPLAY)
{
+ state_mark_attach (s);
state_printf (s, _("[-- %s/%s is unsupported "), TYPE (b), b->subtype);
if (!option (OPTVIEWATTACH))
{
err.data = error;
err.dsize = sizeof (error);
+ /*
+ * XXX - use something even more difficult to predict?
+ */
+ snprintf (AttachmentMarker, sizeof (AttachmentMarker),
+ "\033]9;%ld\a", (long) time (NULL));
+
/* on one of the systems I use, getcwd() does not return the same prefix
as is listed in the passwd file */
if ((p = getenv ("HOME")))
#define state_puts(x,y) fputs(x,(y)->fpout)
#define state_putc(x,y) fputc(x,(y)->fpout)
-void state_prefix_putc(char, STATE *);
+void state_mark_attach (STATE *);
+void state_attach_puts (const char *, STATE *);
+void state_prefix_putc (char, STATE *);
int state_printf(STATE *, const char *, ...);
#include "ascii.h"
return rv;
}
+void state_mark_attach (STATE *s)
+{
+ if ((s->flags & M_DISPLAY) && !mutt_strcmp (Pager, "builtin"))
+ state_puts (AttachmentMarker, s);
+}
+
+void state_attach_puts (const char *t, STATE *s)
+{
+ state_mark_attach (s);
+ state_puts (t, s);
+}
+
void mutt_display_sanitize (char *s)
{
for (; *s; s++)
return class;
}
+static int check_attachment_marker (char *);
+
static void
resolve_types (char *buf, char *raw, struct line_t *lineInfo, int n, int last,
struct q_class_t **QuoteList, int *q_level, int *force_redraw,
}
else if (mutt_strncmp ("\033[0m", raw, 4) == 0) /* a little hack... */
lineInfo[n].type = MT_COLOR_NORMAL;
+#if 0
else if (mutt_strncmp ("[-- ", buf, 4) == 0)
lineInfo[n].type = MT_COLOR_ATTACHMENT;
+#else
+ else if (check_attachment_marker ((char *) raw) == 0)
+ lineInfo[n].type = MT_COLOR_ATTACHMENT;
+#endif
else if (mutt_strcmp ("-- \n", buf) == 0 || mutt_strcmp ("-- \r\n", buf) == 0)
{
i = n + 1;
static int is_ansi (unsigned char *buf)
{
- while (buf && (isdigit(*buf) || *buf == ';'))
+ while (*buf && (isdigit(*buf) || *buf == ';'))
buf++;
return (*buf == 'm');
}
+static int check_attachment_marker (char *p)
+{
+ char *q = AttachmentMarker;
+
+ for (;*p == *q && *q && *p && *q != '\a' && *p != '\a'; p++, q++)
+ ;
+ return (int) (*p - *q);
+}
static int grok_ansi(unsigned char *buf, int pos, ansi_attr *a)
{
else /* ^H */
*fmt++ = *p++;
}
- else if (*p == '\033' && *(p+1) == '[' && is_ansi (p + 2)) /* skip ANSI sequence */
- while (*p++ != 'm')
+ else if (*p == '\033' && *(p+1) == '[' && is_ansi (p + 2))
+ {
+ while (*p++ != 'm') /* skip ANSI sequence */
+ ;
+ }
+ else if (*p == '\033' && *(p+1) == ']' && check_attachment_marker ((char *) p) == 0)
+ {
+ dprint (2, (debugfile, "fill_buffer: Seen attachment marker.\n"));
+ while (*p++ != '\a') /* skip pseudo-ANSI sequence */
;
+ }
else
*fmt++ = *p++;
}
while (cnt-ch >= 2 && buf[ch] == '\033' && buf[ch+1] == '[' &&
is_ansi (buf+ch+2))
ch = grok_ansi (buf, ch+2, pa) + 1;
-
+
+ while (cnt-ch >= 2 && buf[ch] == '\033' && buf[ch+1] == ']' &&
+ check_attachment_marker ((char *) buf+ch) == 0)
+ {
+ while (buf[ch++] != '\a')
+ ;
+ }
+
k = mbrtowc (&wc, (char *)buf+ch, cnt-ch, &mbstate);
if (k == -2 || k == -1)
{
_("[-- PGP output follows (current time: %c) --]\n"),
localtime (&t));
setlocale (LC_TIME, "C");
- state_puts (p, s);
+ state_attach_puts (p, s);
}
pgpin = NULL;
pgperr = NULL;
- state_puts (_("[-- Error: unable to create PGP subprocess! --]\n"), s);
+ state_attach_puts (_("[-- Error: unable to create PGP subprocess! --]\n"), s);
}
else
{
safe_fclose (&pgperr);
if (s->flags & M_DISPLAY)
- state_puts (_("\n[-- End of PGP output --]\n\n"), s);
+ state_attach_puts (_("\n[-- End of PGP output --]\n\n"), s);
}
}
if(s->flags & M_DISPLAY)
{
if (needpass)
- state_puts (_("[-- BEGIN PGP MESSAGE --]\n\n"), s);
+ state_attach_puts (_("[-- BEGIN PGP MESSAGE --]\n\n"), s);
else if (pgp_keyblock)
- state_puts (_("[-- BEGIN PGP PUBLIC KEY BLOCK --]\n"), s);
+ state_attach_puts (_("[-- BEGIN PGP PUBLIC KEY BLOCK --]\n"), s);
else
- state_puts (_("[-- BEGIN PGP SIGNED MESSAGE --]\n\n"), s);
+ state_attach_puts (_("[-- BEGIN PGP SIGNED MESSAGE --]\n\n"), s);
}
/* Use PGP's output if there was no clearsig signature. */
if (s->flags & M_DISPLAY)
{
if (needpass)
- state_puts (_("\n[-- END PGP MESSAGE --]\n"), s);
+ state_attach_puts (_("\n[-- END PGP MESSAGE --]\n"), s);
else if (pgp_keyblock)
- state_puts (_("[-- END PGP PUBLIC KEY BLOCK --]\n"), s);
+ state_attach_puts (_("[-- END PGP PUBLIC KEY BLOCK --]\n"), s);
else
- state_puts (_("\n[-- END PGP SIGNED MESSAGE --]\n"), s);
+ state_attach_puts (_("\n[-- END PGP SIGNED MESSAGE --]\n"), s);
}
}
else
if (needpass == -1)
{
- state_puts (_("[-- Error: could not find beginning of PGP message! --]\n\n"), s);
+ state_attach_puts (_("[-- Error: could not find beginning of PGP message! --]\n\n"), s);
return;
}
}
dprint (1, (debugfile, "pgp_verify_one: mutt_wait_filter returned %d.\n", rv));
}
- state_puts (_("[-- End of PGP output --]\n\n"), s);
+ state_attach_puts (_("[-- End of PGP output --]\n\n"), s);
mutt_unlink (sigfile);
mutt_unlink (pgperrfile);
if (!(a && a->next && a->next->type == protocol_major &&
!ascii_strcasecmp(a->next->subtype, protocol_minor)))
{
- state_puts(_("[-- Error: Inconsistent multipart/signed structure! --]\n\n"), s);
+ state_attach_puts(_("[-- Error: Inconsistent multipart/signed structure! --]\n\n"), s);
mutt_body_handler (a, s);
return;
}
if(!(protocol_major == TYPEAPPLICATION && !ascii_strcasecmp(protocol_minor, "pgp-signature"))
&& !(protocol_major == TYPEMULTIPART && !ascii_strcasecmp(protocol_minor, "mixed")))
{
+ state_mark_attach (s);
state_printf(s, _("[-- Error: Unknown multipart/signed protocol %s! --]\n\n"), protocol);
mutt_body_handler (a, s);
return;
goodsig = 0;
}
else
+ {
+ state_mark_attach (s);
state_printf (s, _("[-- Warning: We can't verify %s/%s signatures. --]\n\n"),
TYPE(signatures[i]), signatures[i]->subtype);
+ }
}
}
dprint (2, (debugfile, "pgp_signed_handler: goodsig = %d\n", goodsig));
/* Now display the signed body */
- state_puts (_("[-- The following data is signed --]\n\n"), s);
+ state_attach_puts (_("[-- The following data is signed --]\n\n"), s);
safe_free((void **) &signatures);
}
else
- state_puts (_("[-- Warning: Can't find any signatures. --]\n\n"), s);
+ state_attach_puts (_("[-- Warning: Can't find any signatures. --]\n\n"), s);
}
mutt_body_handler (a, s);
if (s->flags & M_DISPLAY && sigcnt)
- state_puts (_("\n[-- End of signed data --]\n"), s);
+ state_attach_puts (_("\n[-- End of signed data --]\n"), s);
}
/* Extract pgp public keys from messages or attachments */
fclose (pgperr);
unlink (pgptmpfile);
if (s->flags & M_DISPLAY)
- state_puts (_("[-- Error: could not create a PGP subprocess! --]\n\n"), s);
+ state_attach_puts (_("[-- Error: could not create a PGP subprocess! --]\n\n"), s);
return (NULL);
}
rewind (pgperr);
if (pgp_copy_checksig (pgperr, s->fpout) == 0 && p)
p->goodsig = 1;
- state_puts (_("[-- End of PGP output --]\n\n"), s);
+ state_attach_puts (_("[-- End of PGP output --]\n\n"), s);
}
fclose (pgperr);
ascii_strcasecmp ("octet-stream", a->next->subtype) != 0)
{
if (s->flags & M_DISPLAY)
- state_puts (_("[-- Error: malformed PGP/MIME message! --]\n\n"), s);
+ state_attach_puts (_("[-- Error: malformed PGP/MIME message! --]\n\n"), s);
return;
}
if ((fpout = safe_fopen (tempfile, "w+")) == NULL)
{
if (s->flags & M_DISPLAY)
- state_puts (_("[-- Error: could not create temporary file! --]\n"), s);
+ state_attach_puts (_("[-- Error: could not create temporary file! --]\n"), s);
return;
}
if ((tattach = pgp_decrypt_part (a, s, fpout, p)) != NULL)
{
if (s->flags & M_DISPLAY)
- state_puts (_("[-- The following data is PGP/MIME encrypted --]\n\n"), s);
+ state_attach_puts (_("[-- The following data is PGP/MIME encrypted --]\n\n"), s);
fpin = s->fpin;
s->fpin = fpout;
p->goodsig |= tattach->goodsig;
if (s->flags & M_DISPLAY)
- state_puts (_("\n[-- End of PGP/MIME encrypted data --]\n"), s);
+ state_attach_puts (_("\n[-- End of PGP/MIME encrypted data --]\n"), s);
mutt_free_body (&tattach);
}