addy-0.1.0.0: A full-featured library for parsing, validating, and rendering email addresses

CopyrightThis file is part of the package addy. It is subject to the license
terms in the LICENSE file found in the top-level directory of this
distribution and at:

https://code.devalot.com/open/addy

No part of this package including this file may be copied
modified propagated or distributed except according to the terms
contained in the LICENSE file.
LicenseBSD-2-Clause
Safe HaskellNone
LanguageHaskell2010

Addy.Internal.Parser

Description

Internal parsing functions.

Synopsis

Documentation

data Mode Source #

Parsing mode.

Since: 0.1.0.0

Constructors

Strict

Only support non-obsoleted addresses.

Lenient

Include support for obsolete addresses.

Instances
Eq Mode Source # 
Instance details

Defined in Addy.Internal.Parser

Methods

(==) :: Mode -> Mode -> Bool #

(/=) :: Mode -> Mode -> Bool #

Show Mode Source # 
Instance details

Defined in Addy.Internal.Parser

Methods

showsPrec :: Int -> Mode -> ShowS #

show :: Mode -> String #

showList :: [Mode] -> ShowS #

data Atom Source #

RFC 5322 atom.

Since: 0.1.0.0

Instances
Show Atom Source # 
Instance details

Defined in Addy.Internal.Parser

Methods

showsPrec :: Int -> Atom -> ShowS #

show :: Atom -> String #

showList :: [Atom] -> ShowS #

Semigroup Atom Source # 
Instance details

Defined in Addy.Internal.Parser

Methods

(<>) :: Atom -> Atom -> Atom #

sconcat :: NonEmpty Atom -> Atom #

stimes :: Integral b => b -> Atom -> Atom #

Monoid Atom Source # 
Instance details

Defined in Addy.Internal.Parser

Methods

mempty :: Atom #

mappend :: Atom -> Atom -> Atom #

mconcat :: [Atom] -> Atom #

parse :: Mode -> Parser EmailAddr Source #

An email address parser.

Since: 0.1.0.0

parseWithMode :: Mode -> Text -> Either (NonEmpty Error) EmailAddr Source #

Run the parser and then validate the resulting address.

Since: 0.1.0.0

nameAddr :: Mode -> Parser EmailAddr Source #

Parse email addresses in the name-addr format.

Since: 0.1.0.0

addrSpec :: Mode -> Parser EmailAddr Source #

Parse email addresses in the addr-spec format.

Since: 0.1.0.0

localPartP :: Mode -> Parser (Maybe CommentContent, LocalPart) Source #

Parse the local-part of an email address.

RFC 5322 §3.4.1

local-part = dot-atom / quoted-string / obs-local-part

Since: 0.1.0.0

domainP :: Mode -> Parser (Domain, Maybe CommentContent) Source #

Domain name parser.

Since: 0.1.0.0

displayNameP :: Mode -> Parser Atom Source #

Parse a display name.

Since: 0.1.0.0

word :: Mode -> Parser Atom Source #

An atom or quoted string.

word = atom / quoted-string

Since: 0.1.0.0

atom :: Mode -> Parser Atom Source #

Parse an unquoted atom.

atom            =   [CFWS] 1*atext [CFWS]

Since: 0.1.0.0

dotAtom :: Mode -> Parser Atom Source #

RFC 5322 dot-atom.

Since: 0.1.0.0

dotAtomLh :: Parser Atom Source #

Strict dot-atom-lh from RFC 5322 errata.

dot-atom-lh = [CFWS] dot-atom-text [FWS]

Since: 0.1.0.0

dotAtomRh :: Parser Atom Source #

Strict dot-atom-rh from RFC 5322 errata.

dot-atom-rh = [FWS] dot-atom-text [CFWS]

Since: 0.1.0.0

quoted :: Mode -> Parser Atom Source #

A quoted string.

RFC5322 §3.2.4

qtext           =   %d33 /             ; Printable US-ASCII
                    %d35-91 /          ;  characters not including
                    %d93-126 /         ;  "\" or the quote character
                    obs-qtext

qcontent        =   qtext / quoted-pair

quoted-string   =   [CFWS]
                    DQUOTE *([FWS] qcontent) [FWS] DQUOTE
                    [CFWS]

obs-qtext       =   obs-NO-WS-CTL

RFC 6532 §3.2

qtext   =/  UTF8-non-ascii

RFC 5322 errata item 3135 https://www.rfc-editor.org/errata/eid3135

quoted-string   =   [CFWS]
                    DQUOTE ((1*([FWS] qcontent) [FWS]) / FWS) DQUOTE
                    [CFWS]

This is the rule we use since it's consistent with the text of the RFC.

Since: 0.1.0.0

quotedLh :: Parser Atom Source #

Strict quoted-string-lh from RFC 5322 errata.

Since: 0.1.0.0

cfws :: Mode -> Parser CommentContent Source #

Comments and folding white space.

ctext           =   %d33-39 /          ; Printable US-ASCII
                    %d42-91 /          ;  characters not including
                    %d93-126 /         ;  "(", ")", or "\"
                    obs-ctext

obs-ctext       =   obs-NO-WS-CTL

ccontent        =   ctext / quoted-pair / comment

comment         =   "(" *([FWS] ccontent) [FWS] ")"

CFWS            =   (1*([FWS] comment) [FWS]) / FWS

Since: 0.1.0.0