Altered RFC rules to make it work.

master
Philippe Pittoli 2024-01-31 19:27:16 +01:00
parent 43d8ae9c0b
commit 57fdd3f9d9
1 changed files with 12 additions and 4 deletions

View File

@ -540,18 +540,26 @@ qcontent = CU.singleton <$> qtext <|> quoted_pair
-- | `quoted_string`
-- |
-- | WARNING: this rule was changed in order to take into account the new `qtext` rule,
-- | which now accepts the space character. This new rule, as implemented, still allows
-- | for multiple line returns in the quoted string.
-- |
-- |
-- | Original RFC5322 rule:
-- | quoted-string = `[CFWS] DQUOTE *([FWS] qcontent) [FWS] DQUOTE [CFWS]`
-- |
-- | Implemented rule:
-- | quoted-string = `[CFWS] DQUOTE *([CRLF] qcontent) [FWS] DQUOTE [CFWS]`
quoted_string :: forall e. Parser e String
quoted_string = do s <- tryMaybe cfws
_ <- char '"'
m <- A.many $ do xs <- tryMaybe fws
c <- qcontent
pure $ maybe "" id xs <> c
m <- A.many do l <- tryMaybe crlf
c <- qcontent
pure $ maybe "" id l <> c
_ <- char '"'
e <- tryMaybe cfws
pure $ maybe "" id s <> "\"" <> A.fold m <> "\"" <> maybe "" id e
-- | TODO: For now, `local_part` only checks that
-- | (a) the first character is a letter,
-- | (b) the last character is either a letter or a digit.