Decide how to display email content. More...
#include "config.h"
#include <stddef.h>
#include <ctype.h>
#include <iconv.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "mutt.h"
#include "handler.h"
#include "ncrypt/lib.h"
#include "copy.h"
#include "enriched.h"
#include "keymap.h"
#include "mailcap.h"
#include "mutt_attach.h"
#include "mutt_globals.h"
#include "mutt_logging.h"
#include "muttlib.h"
#include "opcodes.h"
#include "options.h"
#include "pager.h"
#include "rfc3676.h"
#include "state.h"
#include <libintl.h>
Go to the source code of this file.
Macros | |
#define | BUFI_SIZE 1000 |
#define | BUFO_SIZE 2000 |
#define | TXT_HTML 1 |
#define | TXT_PLAIN 2 |
#define | TXT_ENRICHED 3 |
Typedefs | |
typedef int(* | handler_t) (struct Body *b, struct State *s) |
Manage a PGP or S/MIME encrypted MIME part. More... | |
Functions | |
static void | print_part_line (struct State *s, struct Body *b, int n) |
Print a separator for the Mime part. More... | |
static void | convert_to_state (iconv_t cd, char *bufi, size_t *l, struct State *s) |
Convert text and write it to a file. More... | |
static void | decode_xbit (struct State *s, long len, bool istext, iconv_t cd) |
Decode xbit-encoded text. More... | |
static int | qp_decode_triple (char *s, char *d) |
Decode a quoted-printable triplet. More... | |
static void | qp_decode_line (char *dest, char *src, size_t *l, int last) |
Decode a line of quoted-printable text. More... | |
static void | decode_quoted (struct State *s, long len, bool istext, iconv_t cd) |
Decode an attachment encoded with quoted-printable. More... | |
static unsigned char | decode_byte (char ch) |
Decode a uuencoded byte. More... | |
static void | decode_uuencoded (struct State *s, long len, bool istext, iconv_t cd) |
Decode uuencoded text. More... | |
static bool | is_mmnoask (const char *buf) |
Metamail compatibility: should the attachment be autoviewed? More... | |
static bool | is_autoview (struct Body *b) |
Should email body be filtered by mailcap. More... | |
static int | autoview_handler (struct Body *a, struct State *s) |
Handler for autoviewable attachments - Implements handler_t. More... | |
static int | text_plain_handler (struct Body *b, struct State *s) |
Handler for plain text - Implements handler_t. More... | |
static int | message_handler (struct Body *a, struct State *s) |
Handler for message/rfc822 body parts - Implements handler_t. More... | |
static int | external_body_handler (struct Body *b, struct State *s) |
Handler for external-body emails - Implements handler_t. More... | |
static int | alternative_handler (struct Body *a, struct State *s) |
Handler for multipart alternative emails - Implements handler_t. More... | |
static int | multilingual_handler (struct Body *a, struct State *s) |
Handler for multi-lingual emails - Implements handler_t. More... | |
static int | multipart_handler (struct Body *a, struct State *s) |
Handler for multipart emails - Implements handler_t. More... | |
static int | run_decode_and_handler (struct Body *b, struct State *s, handler_t handler, bool plaintext) |
Run an appropriate decoder for an email. More... | |
static int | valid_pgp_encrypted_handler (struct Body *b, struct State *s) |
Handler for valid pgp-encrypted emails - Implements handler_t. More... | |
static int | malformed_pgp_encrypted_handler (struct Body *b, struct State *s) |
Handler for invalid pgp-encrypted emails - Implements handler_t. More... | |
void | mutt_decode_base64 (struct State *s, size_t len, bool istext, iconv_t cd) |
Decode base64-encoded text. More... | |
int | mutt_body_handler (struct Body *b, struct State *s) |
Handler for the Body of an email. More... | |
bool | mutt_can_decode (struct Body *a) |
Will decoding the attachment produce any output. More... | |
void | mutt_decode_attachment (struct Body *b, struct State *s) |
Decode an email's attachment. More... | |
Variables | |
bool | C_HonorDisposition |
Config: Don't display MIME parts inline if they have a disposition of 'attachment'. More... | |
bool | C_ImplicitAutoview |
Config: Display MIME attachments inline if a 'copiousoutput' mailcap entry exists. More... | |
bool | C_IncludeEncrypted |
Config: Whether to include encrypted content when replying. More... | |
bool | C_IncludeOnlyfirst |
Config: Only include the first attachment when replying. More... | |
struct Slist * | C_PreferredLanguages |
Config: Preferred languages for multilingual MIME. More... | |
bool | C_ReflowText |
Config: Reformat paragraphs of 'format=flowed' text. More... | |
char * | C_ShowMultipartAlternative |
Config: How to display 'multipart/alternative' MIME parts. More... | |
Decide how to display email content.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file handler.c.
Print a separator for the Mime part.
s | State of text being processed |
b | Body of the email |
n | Part number for multipart emails (0 otherwise) |
Definition at line 95 of file handler.c.
|
static |
Convert text and write it to a file.
cd | Iconv conversion descriptor |
bufi | Buffer with text to convert |
l | Length of buffer |
s | State to write to |
Definition at line 122 of file handler.c.
|
static |
Decode xbit-encoded text.
s | State to work with |
len | Length of text to decode |
istext | Mime part is plain text |
cd | Iconv conversion descriptor |
Definition at line 171 of file handler.c.
|
static |
|
static |
Decode a line of quoted-printable text.
dest | Buffer for result |
src | Text to decode |
l | Bytes written to buffer |
last | Last character of the line |
Definition at line 240 of file handler.c.
|
static |
Decode an attachment encoded with quoted-printable.
s | State to work with |
len | Length of text to decode |
istext | Mime part is plain text |
cd | Iconv conversion descriptor |
Why doesn't this overflow any buffers? First, it's guaranteed that the length of a line grows when you en-code it to quoted-printable. That means that we always can store the result in a buffer of at most the same size.
Now, we don't special-case if the line we read with fgets() isn't terminated. We don't care about this, since 256 > 78, so corrupted input will just be corrupted a bit more. That implies that 256+1 bytes are always sufficient to store the result of qp_decode_line.
Finally, at soft line breaks, some part of a multibyte character may have been left over by convert_to_state(). This shouldn't be more than 6 characters, so 256+7 should be sufficient memory to store the decoded data.
Just to make sure that I didn't make some off-by-one error above, we just use 512 for the target buffer's size.
Definition at line 308 of file handler.c.
|
static |
|
static |
Decode uuencoded text.
s | State to work with |
len | Length of text to decode |
istext | Mime part is plain text |
cd | Iconv conversion descriptor |
Definition at line 372 of file handler.c.
|
static |
Metamail compatibility: should the attachment be autoviewed?
buf | Mime type, e.g. 'text/plain' |
true | Metamail "no ask" is true |
Test if the MM_NOASK
environment variable should allow autoviewing of the attachment.
MM_NOASK=1
then the function will automatically return true. Definition at line 433 of file handler.c.
|
static |
Should email body be filtered by mailcap.
b | Body of the email |
1 | body part should be filtered by a mailcap entry prior to viewing inline |
0 | otherwise |
Definition at line 484 of file handler.c.
Handler for autoviewable attachments - Implements handler_t.
Definition at line 529 of file handler.c.
Handler for plain text - Implements handler_t.
0 | Always |
When generating format=flowed ($text_flowed is set) from format=fixed, strip all trailing spaces to improve interoperability; if $text_flowed is unset, simply verbatim copy input.
Definition at line 682 of file handler.c.
Handler for message/rfc822 body parts - Implements handler_t.
Definition at line 708 of file handler.c.
Handler for external-body emails - Implements handler_t.
Definition at line 761 of file handler.c.
Handler for multipart alternative emails - Implements handler_t.
Definition at line 932 of file handler.c.
Handler for multi-lingual emails - Implements handler_t.
0 | Always |
Definition at line 1113 of file handler.c.
Handler for multipart emails - Implements handler_t.
Definition at line 1211 of file handler.c.
|
static |
Run an appropriate decoder for an email.
b | Body of the email |
s | State to work with |
handler | Callback function to process the content - Implements handler_t |
plaintext | Is the content in plain text |
0 | Success |
-1 | Error |
Definition at line 1295 of file handler.c.
Handler for valid pgp-encrypted emails - Implements handler_t.
Definition at line 1435 of file handler.c.
Handler for invalid pgp-encrypted emails - Implements handler_t.
Definition at line 1464 of file handler.c.
void mutt_decode_base64 | ( | struct State * | s, |
size_t | len, | ||
bool | istext, | ||
iconv_t | cd | ||
) |
Decode base64-encoded text.
s | State to work with |
len | Length of text to decode |
istext | Mime part is plain text |
cd | Iconv conversion descriptor |
Definition at line 1496 of file handler.c.
Handler for the Body of an email.
0 | Success |
-1 | Error |
Definition at line 1595 of file handler.c.
bool mutt_can_decode | ( | struct Body * | a | ) |
Will decoding the attachment produce any output.
a | Body of email to test |
true | Decoding the attachment will produce output |
Definition at line 1805 of file handler.c.
Decode an email's attachment.
Definition at line 1845 of file handler.c.
bool C_HonorDisposition |
bool C_ImplicitAutoview |
bool C_IncludeEncrypted |
bool C_IncludeOnlyfirst |
struct Slist* C_PreferredLanguages |
bool C_ReflowText |