WIP: RFC5322

master
Philippe Pittoli 2024-01-30 02:06:43 +01:00
parent 59ce971e96
commit 3cd11d3f47
1 changed files with 29 additions and 10 deletions

View File

@ -155,7 +155,15 @@ mailbox_list = do mb <- mailbox
pure $ mb <> A.fold xs pure $ mb <> A.fold xs
<|> obs_mbox_list <|> obs_mbox_list
--address-list = (address *("," address)) / obs-addr-list -- | `address_list`
-- |
-- | address-list = (address *("," address)) / obs-addr-list
address_list :: forall e. Parser e String
address_list = do a <- address
xs <- A.many do _ <- char ','
address
pure $ A.fold $ A.intersperse "," $ [a] <> xs
<|> obs_addr_list
-- | `group_list` -- | `group_list`
-- | -- |
@ -192,7 +200,7 @@ atext = alphanum
<|> char '~' <|> char '~'
-- | `atom` = [CFWS] 1*atext [CFWS] -- | `atom`
-- | -- |
-- | atom = [CFWS] 1*atext [CFWS] -- | atom = [CFWS] 1*atext [CFWS]
atom :: forall e. Parser e String atom :: forall e. Parser e String
@ -210,7 +218,7 @@ dot_atom_text = do xs0 <- many1 atext
str1 = A.fold xs1 str1 = A.fold xs1
pure $ str0 <> str1 pure $ str0 <> str1
-- | dot-atom = [CFWS] dot-atom-text [CFWS] -- | `dot_atom`
-- | -- |
-- | dot-atom = [CFWS] dot-atom-text [CFWS] -- | dot-atom = [CFWS] dot-atom-text [CFWS]
dot_atom :: forall e. Parser e String dot_atom :: forall e. Parser e String
@ -285,7 +293,7 @@ dtext = CU.singleton <$> sat cond <|> obs_dtext
in between 33 90 charcode || between 94 126 charcode in between 33 90 charcode || between 94 126 charcode
-- | TODO: `obs_angle_addr`: obsolete address specification between '<' and '>' characters. -- | `obs_angle_addr`: obsolete address specification between '<' and '>' characters.
-- | -- |
-- | obs-angle-addr = [CFWS] "<" obs-route addr-spec ">" [CFWS] -- | obs-angle-addr = [CFWS] "<" obs-route addr-spec ">" [CFWS]
obs_angle_addr :: forall e. Parser e String obs_angle_addr :: forall e. Parser e String
@ -329,7 +337,18 @@ obs_mbox_list = do _ <- A.many $ do _ <- cfws
pure x pure x
pure $ mb <> A.fold xs pure $ mb <> A.fold xs
--obs-addr-list = *([CFWS] ",") address *("," [address / CFWS]) -- | `obs_addr_list`
-- |
-- | obs-addr-list = *([CFWS] ",") address *("," [address / CFWS])
obs_addr_list :: forall e. Parser e String
obs_addr_list = do _ <- A.many do _ <- tryMaybe cfws
char ','
a <- address
xs <- A.many do _ <- char ','
address <|> do _ <- cfws
pure ""
let res = A.fold $ A.intersperse "," $ [a] <> xs
pure res
-- | `obs_group_list` -- | `obs_group_list`
-- | -- |
@ -406,7 +425,7 @@ obs_qp = do _ <- char '\\'
v <- char_num 0 <|> obs_no_ws_ctl <|> lf <|> cr v <- char_num 0 <|> obs_no_ws_ctl <|> lf <|> cr
pure $ "\\" <> CU.singleton v pure $ "\\" <> CU.singleton v
-- | TODO: `obs_body`: obsolete body. -- | `obs_body`: obsolete body.
-- | -- |
-- | Note: the simpler version found in the errata is implemented, which basically accept everything. -- | Note: the simpler version found in the errata is implemented, which basically accept everything.
-- | -- |
@ -422,12 +441,12 @@ obs_qp = do _ <- char '\\'
-- | obs-body = *(d0 /text / LF / CR) -- | obs-body = *(d0 /text / LF / CR)
-- Errata v1 -- Errata v1
--obs_body :: forall e. Parser e String --obs_body :: forall e. Parser e String
--obs_body = A.fold <$> A.many item --obs_body = CU.fromCharArray <$> A.many item
-- --
-- Errata v2 -- Errata v2
--obs_body :: forall e. Parser e String obs_body :: forall e. Parser e String
--obs_body = A.fold <$> do A.many (char_num 0 <|> vchar <|> lf <|> cr) obs_body = CU.fromCharArray <$> do A.many (char_num 0 <|> vchar <|> lf <|> cr)
--
--obs_body original --obs_body original
--obs_body :: forall e. Parser e String --obs_body :: forall e. Parser e String
--obs_body = do A.many $ do _ <- A.many lf --obs_body = do A.many $ do _ <- A.many lf