From 9ac10570fca04800f04a439e484f41421864b99f Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sat, 27 Jul 2019 20:25:29 +0530 Subject: email: Decode MIME entities without headers. * email/email.scm (email->headers+body): If there are no headers, return "" as headers not an eof-object. (parse-email-body): Parse headers of parent entity or email to parse-mime-entity. (add-default-mime-entity-headers): New function. (parse-mime-entity): Use add-default-mime-entity-headers instead of add-default-headers. Handle MIME entities without headers. * tests/email.scm ("decode MIME entity without headers"): New test. --- tests/email.scm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests') diff --git a/tests/email.scm b/tests/email.scm index 856a5b9..177391e 100644 --- a/tests/email.scm +++ b/tests/email.scm @@ -102,6 +102,23 @@ Content-Length: 4349 (x-mailer . "FooMail 4.0 4.03 (SMT460B92F)") (content-length . "4349"))) +(test-equal "decode MIME entity without headers" + ((module-ref (resolve-module '(email email)) + 'parse-mime-entity) + '((content-type (type . multipart) + (subtype . mixed))) + (string->bytevector + " +This is implicitly typed plain US-ASCII text. +It does NOT end with a linebreak. +" "utf-8")) + (make-mime-entity '((content-type (type . text) + (subtype . plain) + (charset . "utf-8")) + (content-transfer-encoding . 7bit)) + "This is implicitly typed plain US-ASCII text. +It does NOT end with a linebreak.")) + (test-equal "email with 8 bit encoding and non UTF-8 charset" (call-with-input-file "tests/email-with-8bit-encoding-and-non-utf8-charset" (compose parse-email get-bytevector-all)) -- cgit v1.2.3