FreeCalypso > hg > falcon-mail-tools
view f-demime/finish.c @ 2:1857d0d5a7bd
f-demime: fix parsing of Content-* headers
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 06 May 2023 06:33:26 +0000 |
parents | 7e0d08176f32 |
children | 612c4d0df768 |
line wrap: on
line source
/* * This module implements the handling at the end of entity body input. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include "defs.h" extern enum msg_state msg_state; extern char cont_type_buf[HDR_BUF_SIZE], cont_te_buf[HDR_BUF_SIZE]; extern int got_cont_type, got_cont_te; extern int b64_err_flag, b64_nonempty, qpdec_err_flag; static void check_b64_err() { if (b64_err_flag) puts("X-Fdemime-Error: bad base64 data"); } static void check_qpdec_err() { if (qpdec_err_flag) puts("X-Fdemime-Error: bad quoted-printable data"); } void finish_msg_body() { switch (msg_state) { case MSG_STATE_HEADER: if (got_cont_type) fputs(cont_type_buf, stdout); if (got_cont_te) fputs(cont_te_buf, stdout); return; case MSG_STATE_PTEXT_B64: base64_dec_finish(); check_b64_err(); ptext_conv_finish(); ptext_mark_transform("decode-base64"); putchar('\n'); ptext_emit_output(); return; case MSG_STATE_PTEXT_QP: check_qpdec_err(); ptext_conv_finish(); ptext_mark_transform("decode-qp"); putchar('\n'); ptext_emit_output(); return; case MSG_STATE_BLOB_B64: base64_dec_finish(); check_b64_err(); putchar('\n'); attach_out_finish(); if (b64_nonempty) puts("[base64 blob stripped]"); putchar('\n'); return; case MSG_STATE_B64_TO_QP: base64_dec_finish(); check_b64_err(); b2q_conv_finish(); puts("X-Fdemime-Transform: base64-to-qp"); puts("Content-Transfer-Encoding: quoted-printable"); putchar('\n'); b2q_emit_output(); return; } }