From 20e1c2e0059ed9ba366126c1d7637cef19dfd7ce Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sat, 5 Dec 2020 20:10:26 +0530 Subject: email: Support remaining obsolete specification. * email/email.scm (obs-phrase-list, obs-utext, obs-unstruct, obs-optional): New macros. (unstructured, in-reply-to, references, keywords, optional-field): Include obsolete patterns. --- email/email.scm | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/email/email.scm b/email/email.scm index e624a98..da2abf9 100644 --- a/email/email.scm +++ b/email/email.scm @@ -229,13 +229,25 @@ (define-peg-pattern phrase body obs-phrase) +(define-peg-pattern obs-phrase-list body + (and (? (or phrase cfws)) + (* (and "," (or phrase cfws))))) + +(define-peg-pattern obs-utext body + (or "\x00" obs-no-ws-ctl vchar)) + +(define-peg-pattern obs-unstruct body + (* (or (and (* "\n") (* "\r") + (* (and obs-utext (* "\n") (* "\r")))) + fws))) ;; ABNF modified to ignore leading whitespace ;; ABNF modified to allow for blank lines in folded field (define-peg-pattern unstructured body - (and (ignore (? fws)) - (* (and (? fws) (? vchar))) - (ignore (* wsp)))) + (or (and (ignore (? fws)) + (* (and (? fws) (? vchar))) + (ignore (* wsp))) + obs-unstruct)) ;;; Date and time specification @@ -511,14 +523,20 @@ (ignore ">") (ignore (? cfws)))) (define-field-pattern message-id "Message-ID" msg-id) -(define-field-pattern in-reply-to "In-Reply-To" (+ msg-id)) -(define-field-pattern references "References" (+ msg-id)) +(define-field-pattern in-reply-to "In-Reply-To" + (+ msg-id) + (* (or phrase msg-id))) +(define-field-pattern references "References" + (+ msg-id) + (* (or phrase msg-id))) ;;; Informational fields (define-field-pattern subject "Subject" unstructured) (define-field-pattern comments "Comments" unstructured) -(define-field-pattern keywords "Keywords" (and phrase (* (and "," phrase)))) +(define-field-pattern keywords "Keywords" + (and phrase (* (and "," phrase))) + obs-phrase-list) ;;; Resent fields @@ -563,8 +581,12 @@ (define-peg-pattern field-name all (+ ftext)) +(define-peg-pattern obs-optional body + (and field-name (ignore (and (* wsp) ":")) unstructured crlf)) + (define-peg-pattern optional-field all - (and field-name (ignore ":") unstructured crlf)) + (or (and field-name (ignore ":") unstructured crlf) + obs-optional)) ;;; MIME version -- cgit v1.2.3