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` -- | `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]` -- | 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 :: forall e. Parser e String
quoted_string = do s <- tryMaybe cfws quoted_string = do s <- tryMaybe cfws
_ <- char '"' _ <- char '"'
m <- A.many $ do xs <- tryMaybe fws m <- A.many do l <- tryMaybe crlf
c <- qcontent c <- qcontent
pure $ maybe "" id xs <> c pure $ maybe "" id l <> c
_ <- char '"' _ <- char '"'
e <- tryMaybe cfws e <- tryMaybe cfws
pure $ maybe "" id s <> "\"" <> A.fold m <> "\"" <> maybe "" id e pure $ maybe "" id s <> "\"" <> A.fold m <> "\"" <> maybe "" id e
-- | TODO: For now, `local_part` only checks that -- | TODO: For now, `local_part` only checks that
-- | (a) the first character is a letter, -- | (a) the first character is a letter,
-- | (b) the last character is either a letter or a digit. -- | (b) the last character is either a letter or a digit.