diff options
author | Arun Isaac | 2018-10-01 22:58:44 +0530 |
---|---|---|
committer | Arun Isaac | 2018-10-01 23:05:48 +0530 |
commit | fd432bcd88b489913369b82afeea5f15636a2901 (patch) | |
tree | 7e72b9fab32cbf9e7cdec7cce854092ae5d280d9 /email/email.scm | |
parent | 77e1338fc5b3506d5557fae34178f9447c83a72d (diff) | |
download | guile-email-fd432bcd88b489913369b82afeea5f15636a2901.tar.gz guile-email-fd432bcd88b489913369b82afeea5f15636a2901.tar.lz guile-email-fd432bcd88b489913369b82afeea5f15636a2901.zip |
email: Handle truncated messages gracefully.
* email/email.scm (body->mime-entities)[read-mime-entity]: Check for
eof-object so that truncated messages are handled gracefully without
raising an error.
Diffstat (limited to 'email/email.scm')
-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) |