From 2f00e89cc181a9dc9206f2c613789a2e70be1214 Mon Sep 17 00:00:00 2001 From: Ken Hornstein Date: Wed, 29 Jan 2014 15:56:01 -0500 Subject: [PATCH] Beginnings of selectable CTE; allow specification in mhbuild directives, but it doesn't do anything quite yet. --- h/mhparse.h | 1 + uip/mhparse.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/h/mhparse.h b/h/mhparse.h index 29fc1afe..85b1bc16 100644 --- a/h/mhparse.h +++ b/h/mhparse.h @@ -109,6 +109,7 @@ struct Content { /* Content-Transfer-Encoding info (decoded contents) */ struct cefile c_cefile; /* structure holding decoded content */ int c_encoding; /* internal flag for encoding type */ + int c_reqencoding; /* Requested encoding (by mhbuild) */ /* Content-MD5 info */ int c_digested; /* have we seen this header before? */ diff --git a/uip/mhparse.c b/uip/mhparse.c index 716a22f7..371d0c92 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -80,6 +80,19 @@ struct k2v SubApplication[] = { { NULL, APPLICATION_UNKNOWN } /* this one must be last! */ }; +/* + * Mapping of names of CTE types in mhbuild directives + */ +static struct k2v EncodingType[] = { + { "8bit", CE_8BIT }, + { "qp", CE_QUOTED }, + { "q-p", CE_QUOTED }, + { "quoted-printable", CE_QUOTED }, + { "b64", CE_BASE64 }, + { "base64", CE_BASE64 }, + { NULL, 0 }, +}; + /* mhcachesbr.c */ int find_cache (CT, int, int *, char *, char *, int); @@ -838,6 +851,47 @@ magic_skip: cp++; } + /* + * Get any extension directives (right now just the content transfer + * encoding, but maybe others) that we care about. + */ + + if (magic && *cp == '*') { + /* + * See if it's a CTE we match on + */ + struct k2v *kv; + + dp = ++cp; + while (*cp != '\0' && ! isspace((unsigned char) *cp)) + cp++; + + if (dp == cp) { + advise (NULL, "invalid null transfer encoding specification"); + return NOTOK; + } + + if (*cp != '\0') + *cp++ = '\0'; + + ct->c_reqencoding = CE_UNKNOWN; + + for (kv = EncodingType; kv->kv_key; kv++) { + if (strcasecmp(kv->kv_key, dp) == 0) { + ct->c_reqencoding = kv->kv_value; + break; + } + } + + if (ct->c_reqencoding == CE_UNKNOWN) { + advise (NULL, "invalid CTE specification: \"%s\"", dp); + return NOTOK; + } + + while (isspace ((unsigned char) *cp)) + cp++; + } + /* * Check if anything is left over */ -- 2.56.0