diff options
-rw-r--r-- | email/email.scm | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/email/email.scm b/email/email.scm index d836908..1075754 100644 --- a/email/email.scm +++ b/email/email.scm @@ -537,11 +537,15 @@ explained in RFC2045), and return that list." (negate (cut string-prefix? (string-append "--" boundary) <>)))) (define (read-mime-entity port) - (if (string-prefix? (string-append "--" boundary "--") - (get-line-with-delimiter port)) - (eof-object) - (read-till-boundary port))) - + (let ((line (get-line-with-delimiter port))) + ;; The eof-object? check returns #t only when the message is + ;; prematurely truncated. It is invoked only to handle truncated + ;; messages gracefully without raising an error. + (if (or (eof-object? line) + (string-prefix? (string-append "--" boundary "--") line)) + (eof-object) + (read-till-boundary port)))) + (call-with-input-string body (lambda (port) (read-till-boundary port) |