Copyright | (c) 2013 Peter Simons |
---|---|
License | BSD3 |
Maintainer | simons@cryp.to |
Stability | provisional |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
- Useful parser combinators
- Miscellaneous tokens (section 3.2.6)
- Date and Time Specification (section 3.3)
- Address Specification (section 3.4)
- Overall message syntax (section 3.5)
- Field definitions (section 3.6)
- Miscellaneous obsolete tokens (section 4.1)
- Obsolete folding white space (section 4.2)
- Obsolete Date and Time (section 4.3)
- Obsolete Addressing (section 4.4)
- Obsolete header fields (section 4.5)
- Obsolete origination date field (section 4.5.1)
- Obsolete originator fields (section 4.5.2)
- Obsolete destination address fields (section 4.5.3)
- Obsolete identification fields (section 4.5.4)
- Obsolete informational fields (section 4.5.5)
- Obsolete resent fields (section 4.5.6)
- Obsolete trace fields (section 4.5.7)
This module provides parsers for the grammar defined in RFC2822, "Internet Message Format", http://www.faqs.org/rfcs/rfc2822.html.
- maybeOption :: Stream s m Char => ParsecT s u m a -> ParsecT s u m (Maybe a)
- unfold :: Stream s m Char => ParsecT s u m a -> ParsecT s u m a
- header :: Stream s m Char => String -> ParsecT s u m a -> ParsecT s u m a
- obs_header :: Stream s m Char => String -> ParsecT s u m a -> ParsecT s u m a
- no_ws_ctl :: Stream s m Char => ParsecT s u m Char
- text :: Stream s m Char => ParsecT s u m Char
- specials :: Stream s m Char => ParsecT s u m Char
- quoted_pair :: Stream s m Char => ParsecT s u m String
- fws :: Stream s m Char => ParsecT s u m String
- ctext :: Stream s m Char => ParsecT s u m Char
- comment :: Stream s m Char => ParsecT s u m String
- cfws :: Stream s m Char => ParsecT s u m String
- atext :: Stream s m Char => ParsecT s u m Char
- atom :: Stream s m Char => ParsecT s u m String
- dot_atom :: Stream s m Char => ParsecT s u m String
- dot_atom_text :: Stream s m Char => ParsecT s u m String
- qtext :: Stream s m Char => ParsecT s u m Char
- qcontent :: Stream s m Char => ParsecT s u m String
- quoted_string :: Stream s m Char => ParsecT s u m String
- word :: Stream s m Char => ParsecT s u m String
- phrase :: Stream s m Char => ParsecT s u m [String]
- utext :: Stream s m Char => ParsecT s u m Char
- unstructured :: Stream s m Char => ParsecT s u m String
- date_time :: Stream s m Char => ParsecT s u m CalendarTime
- day_of_week :: Stream s m Char => ParsecT s u m Day
- day_name :: Stream s m Char => ParsecT s u m Day
- date :: Stream s m Char => ParsecT s u m (Int, Month, Int)
- year :: Stream s m Char => ParsecT s u m Int
- month :: Stream s m Char => ParsecT s u m Month
- month_name :: Stream s m Char => ParsecT s u m Month
- day_of_month :: Stream s m Char => ParsecT s u m Int
- day :: Stream s m Char => ParsecT s u m Int
- time :: Stream s m Char => ParsecT s u m (TimeDiff, Int)
- time_of_day :: Stream s m Char => ParsecT s u m TimeDiff
- hour :: Stream s m Char => ParsecT s u m Int
- minute :: Stream s m Char => ParsecT s u m Int
- second :: Stream s m Char => ParsecT s u m Int
- zone :: Stream s m Char => ParsecT s u m Int
- data NameAddr = NameAddr {}
- address :: Stream s m Char => ParsecT s u m [NameAddr]
- mailbox :: Stream s m Char => ParsecT s u m NameAddr
- name_addr :: Stream s m Char => ParsecT s u m NameAddr
- angle_addr :: Stream s m Char => ParsecT s u m String
- group :: Stream s m Char => ParsecT s u m [NameAddr]
- display_name :: Stream s m Char => ParsecT s u m String
- mailbox_list :: Stream s m Char => ParsecT s u m [NameAddr]
- address_list :: Stream s m Char => ParsecT s u m [NameAddr]
- addr_spec :: Stream s m Char => ParsecT s u m String
- local_part :: Stream s m Char => ParsecT s u m String
- domain :: Stream s m Char => ParsecT s u m String
- domain_literal :: Stream s m Char => ParsecT s u m String
- dcontent :: Stream s m Char => ParsecT s u m String
- dtext :: Stream s m Char => ParsecT s u m Char
- data GenericMessage a = Message [Field] a
- message :: (Monoid s, Stream s m Char) => ParsecT s u m (GenericMessage s)
- body :: (Monoid s, Monad m) => ParsecT s u m s
- data Field
- = OptionalField String String
- | From [NameAddr]
- | Sender NameAddr
- | ReturnPath String
- | ReplyTo [NameAddr]
- | To [NameAddr]
- | Cc [NameAddr]
- | Bcc [NameAddr]
- | MessageID String
- | InReplyTo [String]
- | References [String]
- | Subject String
- | Comments String
- | Keywords [[String]]
- | Date CalendarTime
- | ResentDate CalendarTime
- | ResentFrom [NameAddr]
- | ResentSender NameAddr
- | ResentTo [NameAddr]
- | ResentCc [NameAddr]
- | ResentBcc [NameAddr]
- | ResentMessageID String
- | ResentReplyTo [NameAddr]
- | Received ([(String, String)], CalendarTime)
- | ObsReceived [(String, String)]
- fields :: Stream s m Char => ParsecT s u m [Field]
- orig_date :: Stream s m Char => ParsecT s u m CalendarTime
- from :: Stream s m Char => ParsecT s u m [NameAddr]
- sender :: Stream s m Char => ParsecT s u m NameAddr
- reply_to :: Stream s m Char => ParsecT s u m [NameAddr]
- to :: Stream s m Char => ParsecT s u m [NameAddr]
- cc :: Stream s m Char => ParsecT s u m [NameAddr]
- bcc :: Stream s m Char => ParsecT s u m [NameAddr]
- message_id :: Stream s m Char => ParsecT s u m String
- in_reply_to :: Stream s m Char => ParsecT s u m [String]
- references :: Stream s m Char => ParsecT s u m [String]
- msg_id :: Stream s m Char => ParsecT s u m String
- id_left :: Stream s m Char => ParsecT s u m String
- id_right :: Stream s m Char => ParsecT s u m String
- no_fold_quote :: Stream s m Char => ParsecT s u m String
- no_fold_literal :: Stream s m Char => ParsecT s u m String
- subject :: Stream s m Char => ParsecT s u m String
- comments :: Stream s m Char => ParsecT s u m String
- keywords :: Stream s m Char => ParsecT s u m [[String]]
- resent_date :: Stream s m Char => ParsecT s u m CalendarTime
- resent_from :: Stream s m Char => ParsecT s u m [NameAddr]
- resent_sender :: Stream s m Char => ParsecT s u m NameAddr
- resent_to :: Stream s m Char => ParsecT s u m [NameAddr]
- resent_cc :: Stream s m Char => ParsecT s u m [NameAddr]
- resent_bcc :: Stream s m Char => ParsecT s u m [NameAddr]
- resent_msg_id :: Stream s m Char => ParsecT s u m String
- return_path :: Stream s m Char => ParsecT s u m String
- path :: Stream s m Char => ParsecT s u m String
- received :: Stream s m Char => ParsecT s u m ([(String, String)], CalendarTime)
- name_val_list :: Stream s m Char => ParsecT s u m [(String, String)]
- name_val_pair :: Stream s m Char => ParsecT s u m (String, String)
- item_name :: Stream s m Char => ParsecT s u m String
- item_value :: Stream s m Char => ParsecT s u m String
- optional_field :: Stream s m Char => ParsecT s u m (String, String)
- field_name :: Stream s m Char => ParsecT s u m String
- ftext :: Stream s m Char => ParsecT s u m Char
- obs_qp :: Stream s m Char => ParsecT s u m String
- obs_text :: Stream s m Char => ParsecT s u m String
- obs_char :: Stream s m Char => ParsecT s u m Char
- obs_utext :: Stream s m Char => ParsecT s u m String
- obs_phrase :: Stream s m Char => ParsecT s u m [String]
- obs_phrase_list :: Stream s m Char => ParsecT s u m [String]
- obs_fws :: Stream s m Char => ParsecT s u m String
- obs_day_of_week :: Stream s m Char => ParsecT s u m Day
- obs_year :: Stream s m Char => ParsecT s u m Int
- obs_month :: Stream s m Char => ParsecT s u m Month
- obs_day :: Stream s m Char => ParsecT s u m Int
- obs_hour :: Stream s m Char => ParsecT s u m Int
- obs_minute :: Stream s m Char => ParsecT s u m Int
- obs_second :: Stream s m Char => ParsecT s u m Int
- obs_zone :: Stream s m Char => ParsecT s u m Int
- obs_angle_addr :: Stream s m Char => ParsecT s u m String
- obs_route :: Stream s m Char => ParsecT s u m [String]
- obs_domain_list :: Stream s m Char => ParsecT s u m [String]
- obs_local_part :: Stream s m Char => ParsecT s u m String
- obs_domain :: Stream s m Char => ParsecT s u m String
- obs_mbox_list :: Stream s m Char => ParsecT s u m [NameAddr]
- obs_addr_list :: Stream s m Char => ParsecT s u m [NameAddr]
- obs_fields :: Stream s m Char => ParsecT s u m [Field]
- obs_orig_date :: Stream s m Char => ParsecT s u m CalendarTime
- obs_from :: Stream s m Char => ParsecT s u m [NameAddr]
- obs_sender :: Stream s m Char => ParsecT s u m NameAddr
- obs_reply_to :: Stream s m Char => ParsecT s u m [NameAddr]
- obs_to :: Stream s m Char => ParsecT s u m [NameAddr]
- obs_cc :: Stream s m Char => ParsecT s u m [NameAddr]
- obs_bcc :: Stream s m Char => ParsecT s u m [NameAddr]
- obs_message_id :: Stream s m Char => ParsecT s u m String
- obs_in_reply_to :: Stream s m Char => ParsecT s u m [String]
- obs_references :: Stream s m Char => ParsecT s u m [String]
- obs_id_left :: Stream s m Char => ParsecT s u m String
- obs_id_right :: Stream s m Char => ParsecT s u m String
- obs_subject :: Stream s m Char => ParsecT s u m String
- obs_comments :: Stream s m Char => ParsecT s u m String
- obs_keywords :: Stream s m Char => ParsecT s u m [String]
- obs_resent_from :: Stream s m Char => ParsecT s u m [NameAddr]
- obs_resent_send :: Stream s m Char => ParsecT s u m NameAddr
- obs_resent_date :: Stream s m Char => ParsecT s u m CalendarTime
- obs_resent_to :: Stream s m Char => ParsecT s u m [NameAddr]
- obs_resent_cc :: Stream s m Char => ParsecT s u m [NameAddr]
- obs_resent_bcc :: Stream s m Char => ParsecT s u m [NameAddr]
- obs_resent_mid :: Stream s m Char => ParsecT s u m String
- obs_resent_reply :: Stream s m Char => ParsecT s u m [NameAddr]
- obs_return :: Stream s m Char => ParsecT s u m String
- obs_received :: Stream s m Char => ParsecT s u m [(String, String)]
- obs_path :: Stream s m Char => ParsecT s u m String
- obs_optional :: Stream s m Char => ParsecT s u m (String, String)
Useful parser combinators
maybeOption :: Stream s m Char => ParsecT s u m a -> ParsecT s u m (Maybe a) Source #
Return Nothing
if the given parser doesn't match. This
combinator is included in the latest parsec distribution as
optionMaybe
, but ghc-6.6.1 apparently doesn't have it.
unfold :: Stream s m Char => ParsecT s u m a -> ParsecT s u m a Source #
unfold
=
between (optional cfws) (optional cfws)
header :: Stream s m Char => String -> ParsecT s u m a -> ParsecT s u m a Source #
Construct a parser for a message header line from the header's name and a parser for the body.
obs_header :: Stream s m Char => String -> ParsecT s u m a -> ParsecT s u m a Source #
Like header
, but allows the obsolete white-space rules.
Primitive Tokens (section 3.2.1)
no_ws_ctl :: Stream s m Char => ParsecT s u m Char Source #
Match any US-ASCII non-whitespace control character.
specials :: Stream s m Char => ParsecT s u m Char Source #
Match any of the RFC's "special" characters: ()<>[]:;@,.\"
.
Quoted characters (section 3.2.2)
quoted_pair :: Stream s m Char => ParsecT s u m String Source #
Match a "quoted pair". All characters matched by text
may be
quoted. Note that the parsers returns both characters, the
backslash and the actual content.
Folding white space and comments (section 3.2.3)
ctext :: Stream s m Char => ParsecT s u m Char Source #
Match any non-whitespace, non-control character except for "(
",
")
", and "\
". This is used to describe the legal content of
comment
s.
Note: This parser accepts 8-bit characters, even though this is not legal according to the RFC. Unfortunately, 8-bit content in comments has become fairly common in the real world, so we'll just accept the fact.
comment :: Stream s m Char => ParsecT s u m String Source #
Match a "comments". That is any combination of ctext
,
quoted_pair
s, and fws
between brackets. Comments may nest.
Atom (section 3.2.4)
dot_atom :: Stream s m Char => ParsecT s u m String Source #
Match dot_atom_text
and skip any preceeding or trailing cfws
.
dot_atom_text :: Stream s m Char => ParsecT s u m String Source #
Match two or more atext
s interspersed by dots.
Quoted strings (section 3.2.5)
qtext :: Stream s m Char => ParsecT s u m Char Source #
Match any non-whitespace, non-control US-ASCII character except
for "\
" and ""
".
Miscellaneous tokens (section 3.2.6)
phrase :: Stream s m Char => ParsecT s u m [String] Source #
Match either one or more word
s or an obs_phrase
.
utext :: Stream s m Char => ParsecT s u m Char Source #
Match any non-whitespace, non-control US-ASCII character except
for "\
" and ""
".
Date and Time Specification (section 3.3)
date_time :: Stream s m Char => ParsecT s u m CalendarTime Source #
Parse a date and time specification of the form
Thu, 19 Dec 2002 20:35:46 +0200
where the weekday specification "Thu,
" is optional. The parser
returns a CalendarTime
, which is set to the appropriate values.
Note, though, that not all fields of CalendarTime
will
necessarily be set correctly! Obviously, when no weekday has been
provided, the parser will set this field to Monday
- regardless
of whether the day actually is a monday or not. Similarly, the day
of the year will always be returned as 0
. The timezone name will
always be empty: ""
.
Nor will the date_time
parser perform any consistency checking.
It will accept
40 Apr 2002 13:12 +0100
as a perfectly valid date.
In order to get all fields set to meaningful values, and in order
to verify the date's consistency, you will have to feed it into any
of the conversion routines provided in System.Time, such as
toClockTime
. (When doing this, keep in mind that most functions
return local time. This will not necessarily be the time you're
expecting.)
day_of_week :: Stream s m Char => ParsecT s u m Day Source #
This parser matches a day_name
or an obs_day_of_week
(optionally
wrapped in folding whitespace) and return its Day
value.
day_name :: Stream s m Char => ParsecT s u m Day Source #
This parser will the abbreviated weekday names ("Mon
", "Tue
", ...)
and return the appropriate Day
value.
date :: Stream s m Char => ParsecT s u m (Int, Month, Int) Source #
This parser will match a date of the form "dd:mm:yyyy
" and return
a tripple of the form (Int,Month,Int) - corresponding to
(year,month,day).
year :: Stream s m Char => ParsecT s u m Int Source #
This parser will match a four digit number and return its integer value. No range checking is performed.
month :: Stream s m Char => ParsecT s u m Month Source #
This parser will match a month_name
, optionally wrapped in
folding whitespace, or an obs_month
and return its Month
value.
month_name :: Stream s m Char => ParsecT s u m Month Source #
This parser will the abbreviated month names ("Jan
", "Feb
", ...)
and return the appropriate Month
value.
day :: Stream s m Char => ParsecT s u m Int Source #
Match a 1 or 2-digit number (day of month), recognizing both standard and obsolete folding syntax.
time :: Stream s m Char => ParsecT s u m (TimeDiff, Int) Source #
This parser will match a time_of_day
specification followed by a
zone
. It returns the tuple (TimeDiff,Int) corresponding to the
return values of either parser.
time_of_day :: Stream s m Char => ParsecT s u m TimeDiff Source #
This parser will match a time-of-day specification of "hh:mm
" or
"hh:mm:ss
" and return the corrsponding time as a TimeDiff
.
hour :: Stream s m Char => ParsecT s u m Int Source #
This parser will match a two-digit number and return its integer value. No range checking is performed.
minute :: Stream s m Char => ParsecT s u m Int Source #
This parser will match a two-digit number and return its integer value. No range checking is performed.
second :: Stream s m Char => ParsecT s u m Int Source #
This parser will match a two-digit number and return its integer value. No range checking takes place.
zone :: Stream s m Char => ParsecT s u m Int Source #
This parser will match a timezone specification of the form
"+hhmm
" or "-hhmm
" and return the zone's offset to UTC in
seconds as an integer. obs_zone
is matched as well.
Address Specification (section 3.4)
A NameAddr is composed of an optional realname a mandatory
e-mail address
.
name_addr :: Stream s m Char => ParsecT s u m NameAddr Source #
Parse an angle_addr
, optionally prefaced with a display_name
,
and return the address.
angle_addr :: Stream s m Char => ParsecT s u m String Source #
Parse an angle_addr
or an obs_angle_addr
and return the address.
group :: Stream s m Char => ParsecT s u m [NameAddr] Source #
Parse a "group" of addresses. That is a display_name
, followed
by a colon, optionally followed by a mailbox_list
, followed by a
semicolon. The found address(es) are returned - what may be none.
Here is an example:
>>>
parse group "" "my group: user1@example.org, user2@example.org;"
Right [NameAddr {nameAddr_name = Nothing, nameAddr_addr = "user1@example.org"},NameAddr {nameAddr_name = Nothing, nameAddr_addr = "user2@example.org"}]
mailbox_list :: Stream s m Char => ParsecT s u m [NameAddr] Source #
Parse a list of mailbox
addresses, every two addresses being
separated by a comma, and return the list of found address(es).
address_list :: Stream s m Char => ParsecT s u m [NameAddr] Source #
Parse a list of address
addresses, every two addresses being
separated by a comma, and return the list of found address(es).
Addr-spec specification (section 3.4.1)
addr_spec :: Stream s m Char => ParsecT s u m String Source #
Parse an "address specification". That is a local_part
, followed
by an "@
" character, followed by a domain
. Return the complete
address as String
, ignoring any whitespace or any comments.
local_part :: Stream s m Char => ParsecT s u m String Source #
Parse and return a "local part" of an addr_spec
. That is either
a dot_atom
or a quoted_string
.
domain :: Stream s m Char => ParsecT s u m String Source #
Parse and return a "domain part" of an addr_spec
. That is either
a dot_atom
or a domain_literal
.
domain_literal :: Stream s m Char => ParsecT s u m String Source #
Parse a "domain literal". That is a "[
" character, followed by
any amount of dcontent
, followed by a terminating "]
"
character. The complete string is returned verbatim.
dcontent :: Stream s m Char => ParsecT s u m String Source #
Parse and return any characters that are legal in a
domain_literal
. That is dtext
or a quoted_pair
.
dtext :: Stream s m Char => ParsecT s u m Char Source #
Parse and return any ASCII characters except "[
", "]
", and
"\
".
Overall message syntax (section 3.5)
data GenericMessage a Source #
This data type repesents a parsed Internet Message as defined in
this RFC. It consists of an arbitrary number of header lines,
represented in the Field
data type, and a message body, which may
be empty.
Show a => Show (GenericMessage a) Source # | |
message :: (Monoid s, Stream s m Char) => ParsecT s u m (GenericMessage s) Source #
Parse a complete message as defined by this RFC and it broken down
into the separate header fields and the message body. Header lines,
which contain syntax errors, will not cause the parser to abort.
Rather, these headers will appear as OptionalField
s (which are
unparsed) in the resulting Message
. A message must be really,
really badly broken for this parser to fail.
This behaviour was chosen because it is impossible to predict what the user of this module considers to be a fatal error; traditionally, parsers are very forgiving when it comes to Internet messages.
If you want to implement a really strict parser, you'll have to put
the appropriate parser together yourself. You'll find that this is
rather easy to do. Refer to the fields
parser for further details.
body :: (Monoid s, Monad m) => ParsecT s u m s Source #
A message body is just an unstructured sequence of characters.
Field definitions (section 3.6)
This data type represents any of the header fields defined in this RFC. Each of the various instances contains with the return value of the corresponding parser.
fields :: Stream s m Char => ParsecT s u m [Field] Source #
This parser will parse an arbitrary number of header fields as
defined in this RFC. For each field, an appropriate Field
value
is created, all of them making up the Field
list that this parser
returns.
If you look at the implementation of this parser, you will find
that it uses Parsec's try
modifier around all of the fields.
The idea behind this is that fields, which contain syntax errors,
fall back to the catch-all optional_field
. Thus, this parser will
hardly ever return a syntax error -- what conforms with the idea
that any message that can possibly be accepted should be.
The origination date field (section 3.6.1)
orig_date :: Stream s m Char => ParsecT s u m CalendarTime Source #
Parse a "Date:
" header line and return the date it contains a
CalendarTime
.
Originator fields (section 3.6.2)
from :: Stream s m Char => ParsecT s u m [NameAddr] Source #
Parse a "From:
" header line and return the mailbox_list
address(es) contained in it.
sender :: Stream s m Char => ParsecT s u m NameAddr Source #
Parse a "Sender:
" header line and return the mailbox
address
contained in it.
reply_to :: Stream s m Char => ParsecT s u m [NameAddr] Source #
Parse a "Reply-To:
" header line and return the address_list
address(es) contained in it.
Destination address fields (section 3.6.3)
to :: Stream s m Char => ParsecT s u m [NameAddr] Source #
Parse a "To:
" header line and return the address_list
address(es) contained in it.
cc :: Stream s m Char => ParsecT s u m [NameAddr] Source #
Parse a "Cc:
" header line and return the address_list
address(es) contained in it.
bcc :: Stream s m Char => ParsecT s u m [NameAddr] Source #
Parse a "Bcc:
" header line and return the address_list
address(es) contained in it.
Identification fields (section 3.6.4)
message_id :: Stream s m Char => ParsecT s u m String Source #
Parse a "Message-Id:
" header line and return the msg_id
contained in it.
in_reply_to :: Stream s m Char => ParsecT s u m [String] Source #
Parse a "In-Reply-To:
" header line and return the list of
msg_id
s contained in it.
references :: Stream s m Char => ParsecT s u m [String] Source #
Parse a "References:
" header line and return the list of
msg_id
s contained in it.
msg_id :: Stream s m Char => ParsecT s u m String Source #
Parse a "message ID:
" and return it. A message ID is almost
identical to an angle_addr
, but with stricter rules about folding
and whitespace.
id_left :: Stream s m Char => ParsecT s u m String Source #
Parse a "left ID" part of a msg_id
. This is almost identical to
the local_part
of an e-mail address, but with stricter rules
about folding and whitespace.
no_fold_quote :: Stream s m Char => ParsecT s u m String Source #
Parse one or more occurences of qtext
or quoted_pair
and
return the concatenated string. This makes up the id_left
of a
msg_id
.
no_fold_literal :: Stream s m Char => ParsecT s u m String Source #
Parse one or more occurences of dtext
or quoted_pair
and
return the concatenated string. This makes up the id_right
of a
msg_id
.
Informational fields (section 3.6.5)
subject :: Stream s m Char => ParsecT s u m String Source #
Parse a "Subject:
" header line and return its contents verbatim.
Please note that all whitespace and/or comments are preserved, i.e.
the result of parsing "Subject: foo"
is " foo"
, not "foo"
.
comments :: Stream s m Char => ParsecT s u m String Source #
Parse a "Comments:
" header line and return its contents verbatim.
Please note that all whitespace and/or comments are preserved, i.e.
the result of parsing "Comments: foo"
is " foo"
, not "foo"
.
Resent fields (section 3.6.6)
resent_date :: Stream s m Char => ParsecT s u m CalendarTime Source #
Parse a "Resent-Date:
" header line and return the date it
contains as CalendarTime
.
resent_from :: Stream s m Char => ParsecT s u m [NameAddr] Source #
Parse a "Resent-From:
" header line and return the mailbox_list
address(es) contained in it.
resent_sender :: Stream s m Char => ParsecT s u m NameAddr Source #
Parse a "Resent-Sender:
" header line and return the mailbox_list
address(es) contained in it.
resent_to :: Stream s m Char => ParsecT s u m [NameAddr] Source #
Parse a "Resent-To:
" header line and return the mailbox
address contained in it.
resent_cc :: Stream s m Char => ParsecT s u m [NameAddr] Source #
Parse a "Resent-Cc:
" header line and return the address_list
address(es) contained in it.
resent_bcc :: Stream s m Char => ParsecT s u m [NameAddr] Source #
Parse a "Resent-Bcc:
" header line and return the address_list
address(es) contained in it. (This list may be empty.)
resent_msg_id :: Stream s m Char => ParsecT s u m String Source #
Parse a "Resent-Message-ID:
" header line and return the msg_id
contained in it.
Trace fields (section 3.6.7)
Optional fields (section 3.6.8)
optional_field :: Stream s m Char => ParsecT s u m (String, String) Source #
Parse an arbitrary header field and return a tuple containing the
field_name
and unstructured
text of the header. The name will
not contain the terminating colon.
field_name :: Stream s m Char => ParsecT s u m String Source #
Parse and return an arbitrary header field name. That is one or
more ftext
characters.
ftext :: Stream s m Char => ParsecT s u m Char Source #
Match and return any ASCII character except for control
characters, whitespace, and ":
".
Miscellaneous obsolete tokens (section 4.1)
obs_qp :: Stream s m Char => ParsecT s u m String Source #
Match the obsolete "quoted pair" syntax, which - unlike
quoted_pair
- allowed any ASCII character to be specified when
quoted. The parser will return both, the backslash and the actual
character.
obs_text :: Stream s m Char => ParsecT s u m String Source #
Match the obsolete "text" syntax, which - unlike text
- allowed
"carriage returns" and "linefeeds". This is really weird; you
better consult the RFC for details. The parser will return the
complete string, including those special characters.
obs_char :: Stream s m Char => ParsecT s u m Char Source #
Match and return the obsolete "char" syntax, which - unlike
character
- did not allow "carriage return" and "linefeed".
obs_utext :: Stream s m Char => ParsecT s u m String Source #
Match and return the obsolete "utext" syntax, which is identical
to obs_text
.
obs_phrase :: Stream s m Char => ParsecT s u m [String] Source #
Match the obsolete "phrase" syntax, which - unlike phrase
-
allows dots between tokens.
obs_phrase_list :: Stream s m Char => ParsecT s u m [String] Source #
Match a "phrase list" syntax and return the list of String
s
that make up the phrase. In contrast to a phrase
, the
obs_phrase_list
separates the individual words by commas. This
syntax is - as you will have guessed - obsolete.
Obsolete folding white space (section 4.2)
Obsolete Date and Time (section 4.3)
obs_day_of_week :: Stream s m Char => ParsecT s u m Day Source #
Parse a day_name
but allow for the obsolete folding syntax.
obs_year :: Stream s m Char => ParsecT s u m Int Source #
Parse a year
but allow for a two-digit number (obsolete) and the
obsolete folding syntax.
obs_month :: Stream s m Char => ParsecT s u m Month Source #
Parse a month_name
but allow for the obsolete folding syntax.
obs_day :: Stream s m Char => ParsecT s u m Int Source #
Parse a day
but allow for the obsolete folding syntax.
obs_hour :: Stream s m Char => ParsecT s u m Int Source #
Parse a hour
but allow for the obsolete folding syntax.
obs_minute :: Stream s m Char => ParsecT s u m Int Source #
Parse a minute
but allow for the obsolete folding syntax.
obs_second :: Stream s m Char => ParsecT s u m Int Source #
Parse a second
but allow for the obsolete folding syntax.
obs_zone :: Stream s m Char => ParsecT s u m Int Source #
Match the obsolete zone names and return the appropriate offset.
Obsolete Addressing (section 4.4)
obs_angle_addr :: Stream s m Char => ParsecT s u m String Source #
This parser matches the "obsolete angle address" syntax, a construct that
used to be called "route address" in earlier RFCs. It differs from a
standard angle_addr
in two ways: (1) it allows far more
liberal insertion of folding whitespace and comments and (2) the address may
contain a "route" (which this parser ignores):
>>>
parse obs_angle_addr "" "<@example1.org,@example2.org:joe@example.org>"
Right "<joe@example.org>"
obs_route :: Stream s m Char => ParsecT s u m [String] Source #
This parser parses the "route" part of obs_angle_addr
and
returns the list of String
s that make up this route. Relies on
obs_domain_list
for the actual parsing.
obs_domain_list :: Stream s m Char => ParsecT s u m [String] Source #
This parser parses a list of domain names, each of them prefaced
with an "at". Multiple names are separated by a comma. The list of
domain
s is returned - and may be empty.
obs_local_part :: Stream s m Char => ParsecT s u m String Source #
Parse the obsolete syntax of a local_part
, which allowed for
more liberal insertion of folding whitespace and comments. The
actual string is returned.
obs_domain :: Stream s m Char => ParsecT s u m String Source #
Parse the obsolete syntax of a domain
, which allowed for more
liberal insertion of folding whitespace and comments. The actual
string is returned.
obs_mbox_list :: Stream s m Char => ParsecT s u m [NameAddr] Source #
This parser will match the obsolete syntax for a mailbox_list
.
This one is quite weird: An obs_mbox_list
contains an arbitrary
number of mailbox
es - including none -, which are separated by
commas. But you may have multiple consecutive commas without giving
a mailbox
. You may also have a valid obs_mbox_list
that
contains no mailbox
at all. On the other hand, you must have
at least one comma. The following example is valid:
>>>
parse obs_mbox_list "" ","
Right []
But this one is not:
>>>
parse obs_mbox_list "" "joe@example.org"
Left (line 1, column 16): unexpected end of input expecting obsolete syntax for a list of mailboxes
obs_addr_list :: Stream s m Char => ParsecT s u m [NameAddr] Source #
This parser is identical to obs_mbox_list
but parses a list of
address
es rather than mailbox
es. The main difference is that an
address
may contain group
s. Please note that as of now, the
parser will return a simple list of addresses; the grouping
information is lost.
Obsolete header fields (section 4.5)
Obsolete origination date field (section 4.5.1)
obs_orig_date :: Stream s m Char => ParsecT s u m CalendarTime Source #
Parse a date
header line but allow for the obsolete
folding syntax.
Obsolete originator fields (section 4.5.2)
obs_from :: Stream s m Char => ParsecT s u m [NameAddr] Source #
Parse a from
header line but allow for the obsolete
folding syntax.
obs_sender :: Stream s m Char => ParsecT s u m NameAddr Source #
Parse a sender
header line but allow for the obsolete
folding syntax.
obs_reply_to :: Stream s m Char => ParsecT s u m [NameAddr] Source #
Parse a reply_to
header line but allow for the obsolete
folding syntax.
Obsolete destination address fields (section 4.5.3)
obs_to :: Stream s m Char => ParsecT s u m [NameAddr] Source #
Parse a to
header line but allow for the obsolete
folding syntax.
obs_cc :: Stream s m Char => ParsecT s u m [NameAddr] Source #
Parse a cc
header line but allow for the obsolete
folding syntax.
obs_bcc :: Stream s m Char => ParsecT s u m [NameAddr] Source #
Parse a bcc
header line but allow for the obsolete
folding syntax.
Obsolete identification fields (section 4.5.4)
obs_message_id :: Stream s m Char => ParsecT s u m String Source #
Parse a message_id
header line but allow for the obsolete
folding syntax.
obs_in_reply_to :: Stream s m Char => ParsecT s u m [String] Source #
Parse an in_reply_to
header line but allow for the obsolete
folding and the obsolete phrase syntax.
obs_references :: Stream s m Char => ParsecT s u m [String] Source #
Parse a references
header line but allow for the obsolete
folding and the obsolete phrase syntax.
obs_id_left :: Stream s m Char => ParsecT s u m String Source #
Parses the "left part" of a message ID, but allows the obsolete
syntax, which is identical to a local_part
.
obs_id_right :: Stream s m Char => ParsecT s u m String Source #
Parses the "right part" of a message ID, but allows the obsolete
syntax, which is identical to a domain
.
Obsolete informational fields (section 4.5.5)
obs_subject :: Stream s m Char => ParsecT s u m String Source #
Parse a subject
header line but allow for the obsolete
folding syntax.
obs_comments :: Stream s m Char => ParsecT s u m String Source #
Parse a comments
header line but allow for the obsolete
folding syntax.
obs_keywords :: Stream s m Char => ParsecT s u m [String] Source #
Parse a keywords
header line but allow for the obsolete
folding syntax. Also, this parser accepts obs_phrase_list
.
Obsolete resent fields (section 4.5.6)
obs_resent_from :: Stream s m Char => ParsecT s u m [NameAddr] Source #
Parse a resent_from
header line but allow for the obsolete
folding syntax.
obs_resent_send :: Stream s m Char => ParsecT s u m NameAddr Source #
Parse a resent_sender
header line but allow for the obsolete
folding syntax.
obs_resent_date :: Stream s m Char => ParsecT s u m CalendarTime Source #
Parse a resent_date
header line but allow for the obsolete
folding syntax.
obs_resent_to :: Stream s m Char => ParsecT s u m [NameAddr] Source #
Parse a resent_to
header line but allow for the obsolete
folding syntax.
obs_resent_cc :: Stream s m Char => ParsecT s u m [NameAddr] Source #
Parse a resent_cc
header line but allow for the obsolete
folding syntax.
obs_resent_bcc :: Stream s m Char => ParsecT s u m [NameAddr] Source #
Parse a resent_bcc
header line but allow for the obsolete
folding syntax.
obs_resent_mid :: Stream s m Char => ParsecT s u m String Source #
Parse a resent_msg_id
header line but allow for the obsolete
folding syntax.
obs_resent_reply :: Stream s m Char => ParsecT s u m [NameAddr] Source #
Parse a Resent-Reply-To
header line but allow for the
obsolete folding syntax.
Obsolete trace fields (section 4.5.7)
obs_optional :: Stream s m Char => ParsecT s u m (String, String) Source #
This parser is identical to optional_field
but allows the more
liberal line-folding syntax between the "field_name" and the "field
text".