tCheck Content-Transfer-Encoding header field to be "8bit" - scribo - Email-based phlog generator
(HTM) git clone git://git.z3bra.org/scribo.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit d09787997bb6279189f3c39ef921ff2c1853a74d
(DIR) parent 1e2c694a88f3fb5f1cc3c42d9e079495cd530a83
(HTM) Author: Willy Goiffon <dev@z3bra.org>
Date: Tue, 8 Sep 2020 15:25:43 +0200
Check Content-Transfer-Encoding header field to be "8bit"
Diffstat:
M scribo.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
---
(DIR) diff --git a/scribo.c b/scribo.c
t@@ -131,6 +131,8 @@ parseheaders(FILE *fp, struct headers *head)
int
verifyheaders(struct headers *head)
{
+ char *addr, *type, *encoding;
+
if (!head)
return -1;
t@@ -149,18 +151,23 @@ verifyheaders(struct headers *head)
return -1;
}
- if (!header(head, "Content-Type")) {
- fprintf(stderr, "Missing header: Content-Type\n");
+
+ /* only accept plain text emails */
+ type = header(head, "Content-Type");
+ if (type && strncmp(type, "text/plain", 10)) {
+ fprintf(stderr, "Content-Type: %s is not supported\n", type);
return -1;
}
- /* only accept plain text emails */
- if (strncmp(header(head, "Content-Type"), "text/plain", 10)) {
- fprintf(stderr, "Invalid Content-Type: %s\n", header(head, "Content-Type"));
+ /* ensure message body is unaltered */
+ encoding = header(head, "Content-Transfer-Encoding");
+ if (encoding && strncmp(encoding, "8bit", 4)) {
+ fprintf(stderr, "Content-Transfer-Encoding: %s is not supported\n", encoding);
return -1;
}
- char *addr = rfc5322_addr(header(head, "From"));
+ /* verify sender's address */
+ addr = rfc5322_addr(header(head, "From"));
if (strncmp(addr, author, strlen(author))) {
fprintf(stderr, "<%s> is not authorized to publish content\n", addr);
return -1;