193
193
if (!soft && last == '\n')
195
/* neither \r nor \n as part of line-terminating CRLF
196
* may be qp-encoded, so remove \r and \n-terminate;
197
* see RfC2045, sect. 6.7, (1): General 8bit representation */
198
if (kind == 0 && c == '\r')
427
435
RICH_FLUSHRIGHT, RICH_COLOR, RICH_LAST_TAG };
430
const char *tag_name;
438
const wchar_t *tag_name;
432
440
} EnrichedTags[] = {
433
{ "param", RICH_PARAM },
434
{ "bold", RICH_BOLD },
435
{ "italic", RICH_ITALIC },
436
{ "underline", RICH_UNDERLINE },
437
{ "nofill", RICH_NOFILL },
438
{ "excerpt", RICH_EXCERPT },
439
{ "indent", RICH_INDENT },
440
{ "indentright", RICH_INDENT_RIGHT },
441
{ "center", RICH_CENTER },
442
{ "flushleft", RICH_FLUSHLEFT },
443
{ "flushright", RICH_FLUSHRIGHT },
444
{ "flushboth", RICH_FLUSHLEFT },
445
{ "color", RICH_COLOR },
446
{ "x-color", RICH_COLOR },
441
{ L"param", RICH_PARAM },
442
{ L"bold", RICH_BOLD },
443
{ L"italic", RICH_ITALIC },
444
{ L"underline", RICH_UNDERLINE },
445
{ L"nofill", RICH_NOFILL },
446
{ L"excerpt", RICH_EXCERPT },
447
{ L"indent", RICH_INDENT },
448
{ L"indentright", RICH_INDENT_RIGHT },
449
{ L"center", RICH_CENTER },
450
{ L"flushleft", RICH_FLUSHLEFT },
451
{ L"flushright", RICH_FLUSHRIGHT },
452
{ L"flushboth", RICH_FLUSHLEFT },
453
{ L"color", RICH_COLOR },
454
{ L"x-color", RICH_COLOR },
469
static int enriched_cmp (const char *a, const wchar_t *b)
471
register const char *p = a;
472
register const wchar_t *q = b;
482
for ( ; *p || *q; p++, q++)
484
if ((i = ascii_tolower (*p)) - ascii_tolower (((char) *q) & 0x7f))
490
477
static void enriched_wrap (struct enriched_state *stte)
734
722
if ((stte->s->flags & M_DISPLAY) && j == RICH_PARAM && stte->tag_level[RICH_COLOR])
736
724
stte->param[stte->param_used] = (wchar_t) '\0';
737
if (!enriched_cmp("black", stte->param))
725
if (!wcscasecmp(L"black", stte->param))
739
727
enriched_puts("\033[30m", stte);
741
else if (!enriched_cmp("red", stte->param))
729
else if (!wcscasecmp(L"red", stte->param))
743
731
enriched_puts("\033[31m", stte);
745
else if (!enriched_cmp("green", stte->param))
733
else if (!wcscasecmp(L"green", stte->param))
747
735
enriched_puts("\033[32m", stte);
749
else if (!enriched_cmp("yellow", stte->param))
737
else if (!wcscasecmp(L"yellow", stte->param))
751
739
enriched_puts("\033[33m", stte);
753
else if (!enriched_cmp("blue", stte->param))
741
else if (!wcscasecmp(L"blue", stte->param))
755
743
enriched_puts("\033[34m", stte);
757
else if (!enriched_cmp("magenta", stte->param))
745
else if (!wcscasecmp(L"magenta", stte->param))
759
747
enriched_puts("\033[35m", stte);
761
else if (!enriched_cmp("cyan", stte->param))
749
else if (!wcscasecmp(L"cyan", stte->param))
763
751
enriched_puts("\033[36m", stte);
765
else if (!enriched_cmp("white", stte->param))
753
else if (!wcscasecmp(L"white", stte->param))
767
755
enriched_puts("\033[37m", stte);
1102
1090
mutt_copy_hdr (s->fpin, s->fpout, off_start, b->parts->offset,
1103
1091
(((s->flags & M_WEED) || ((s->flags & (M_DISPLAY|M_PRINTING)) && option (OPTWEED))) ? (CH_WEED | CH_REORDER) : 0) |
1104
(s->prefix ? CH_PREFIX : 0) | CH_DECODE | CH_FROM, s->prefix);
1092
(s->prefix ? CH_PREFIX : 0) | CH_DECODE | CH_FROM |
1093
(s->flags & M_DISPLAY) ? CH_DISPLAY : 0, s->prefix);
1107
1096
state_puts (s->prefix, s);
1207
1196
state_putc ('\n', s);
1211
if (p->description && mutt_can_decode (p))
1212
state_printf (s, "Content-Description: %s\n", p->description);
1215
state_printf(s, "%s: \n", p->form_name);
1218
1199
rc = mutt_body_handler (p, s);
1219
1200
state_putc ('\n', s);
1505
1486
iconv_close (cd);
1489
/* when generating format=flowed ($text_flowed is set) from format=fixed,
1490
* strip all trailing spaces to improve interoperability;
1491
* if $text_flowed is unset, simply verbatim copy input
1493
static int text_plain_handler (BODY *b, STATE *s)
1495
char buf[LONG_STRING];
1498
while (fgets (buf, sizeof (buf), s->fpin))
1500
l = mutt_strlen (buf);
1501
if (l > 0 && buf[l-1] == '\n')
1503
if (option (OPTTEXTFLOWED))
1505
while (l > 0 && buf[l-1] == ' ')
1509
state_puts (s->prefix, s);
1510
state_puts (buf, s);
1511
state_putc ('\n', s);
1508
1517
int mutt_body_handler (BODY *b, STATE *s)
1510
1519
int decode = 0;
1545
1554
else if (ascii_strcasecmp ("flowed", mutt_get_parameter ("format", b->parameter)) == 0)
1546
1555
handler = rfc3676_handler;
1557
handler = text_plain_handler;
1550
1559
else if (ascii_strcasecmp ("enriched", b->subtype) == 0)
1551
1560
handler = text_enriched_handler;
1612
1621
handler = crypt_smime_application_smime_handler;
1616
if (plaintext || handler)
1624
/* only respect disposition == attachment if we're not
1625
displaying from the attachment menu (i.e. pager) */
1626
if ((!option (OPTHONORDISP) || (b->disposition != DISPATTACH ||
1627
option(OPTVIEWATTACH))) &&
1628
(plaintext || handler))
1618
1630
fseeko (s->fpin, b->offset, 0);
1694
1706
b->offset = tmpoffset;
1696
1708
/* restore the original source stream */
1709
safe_fclose (&s->fpin);
1701
1713
s->flags |= M_FIRSTDONE;
1703
else if (s->flags & M_DISPLAY)
1715
/* print hint to use attachment menu for disposition == attachment
1716
if we're not already being called from there */
1717
else if ((s->flags & M_DISPLAY) || (b->disposition == DISPATTACH &&
1718
!option (OPTVIEWATTACH) &&
1719
option (OPTHONORDISP) &&
1720
(plaintext || handler)))
1705
1722
state_mark_attach (s);
1706
state_printf (s, _("[-- %s/%s is unsupported "), TYPE (b), b->subtype);
1723
if (option (OPTHONORDISP) && b->disposition == DISPATTACH)
1724
fputs (_("[-- This is an attachment "), s->fpout);
1726
state_printf (s, _("[-- %s/%s is unsupported "), TYPE (b), b->subtype);
1707
1727
if (!option (OPTVIEWATTACH))
1709
1729
if (km_expand_key (type, sizeof(type),