diff options
Diffstat (limited to 'email/email.scm')
-rw-r--r-- | email/email.scm | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/email/email.scm b/email/email.scm index 5e1ef9d..d37b2a9 100644 --- a/email/email.scm +++ b/email/email.scm @@ -79,35 +79,34 @@ (headers mime-entity-headers) (body mime-entity-body)) -(define (sanitize-field email field) - "Sanitize @var{field} value in @var{email} and return a new sanitized -value." +(define (validate-field email field) + "Validate @var{field} value in @var{email}. Return @code{#f} if value +is invalid. Else, return the value unchanged." (let ((field-value (assq-ref (email-headers email) field))) - (if (string? field-value) - ;; Invalid fields show up as strings in the parse tree. - ;; Discard them and return an empty list. - (list) - field-value))) + ;; Invalid fields show up as strings in the parse tree. Discard + ;; them and return #f. + (and (not (string? field-value)) + field-value))) (define (email-from email) "Return list of From addresses in @var{email}." - (or (sanitize-field email 'from) + (or (validate-field email 'from) (list))) (define (email-to email) "Return list of To addresses in @var{email}." - (or (sanitize-field email 'to) + (or (validate-field email 'to) (list))) (define (email-cc email) "Return list of Cc addresses in @var{email}." - (or (sanitize-field email 'cc) + (or (validate-field email 'cc) (list))) (define (email-bcc email) "Return list of Bcc addresses in @var{email}." - (or (sanitize-field email 'bcc) + (or (validate-field email 'bcc) (list))) (define (email-subject email) @@ -117,7 +116,7 @@ value." (define (email-date email) "Return Date of @var{email}." - (sanitize-field email 'date)) + (validate-field email 'date)) (define (email-message-id email) "Return Message-ID of @var{email}." |