~/bend-docscommunity

addr.bend checks

raw source on the hub · import 0xfd64aefef43747d3eaeea50c10a112e5/addr.bend as Addr

Addresses and mailboxes. An address is local@domain, a dot-atom (RFC 5321 4.1.2; RFC 6531 3.3 for UTF-8); a mailbox is an address with an optional display name, "Maria Silva <maria@example.com>" (RFC 5322 3.4). Lists are read the way people write them, commas inside quotes or angle brackets included, and written back as header values.

4 imports
import Base
import ./text.bend as T
import ./mime.bend as M
import ./idna.bend as I

Types

type Mbox source · line 11 · raw

Data

type Cut source · line 148 · raw

Data

Where a list split is: inside quotes, after a backslash in them, inside angle brackets; the item so far (reversed) and the items (reversed).

Definitions

def Addr.atext source · line 18 · raw

@+c:U32 -> Bool

atext (RFC 5322 3.2.3): letters, digits and !#$%&'*+-/=?^_`{|}~.

def Addr.local.ok source · line 26 · raw

@s:String -> Bool

Local part chars: atext, ".", and any non-ASCII (RFC 6531 3.3).

def Addr.domain.ok source · line 34 · raw

@s:String -> Bool

Domain chars: letters, digits, "-", "." and non-ASCII (a U-label).

def Addr.dots source · line 44 · raw

@+s:String -> Bool

Dots only between other chars.

def Addr.parts source · line 48 · raw

@parts:List<&2, String> -> Bool

def Addr.ok source · line 58 · raw

@+a:String -> Bool

A dot-atom address: no quoting, no route, local part up to 64 octets, all up to 254.

def Addr.domain.of source · line 62 · raw

@parts:List<&2, String> -> String

def Addr.domain source · line 69 · raw

@a:String -> String

def Addr.local source · line 72 · raw

@parts:List<&2, String> -> String

def Addr.ascii.of source · line 79 · raw

@parts:List<&2, String> -> String

def Addr.ascii source · line 87 · raw

@a:String -> String

The address with its domain as A-labels (RFC 5890).

def Addr.utf8 source · line 91 · raw

@a:String -> Bool

Whether a local part has non-ASCII, which only SMTPUTF8 can carry.

def Mbox.addr source · line 97 · raw

@m:Mbox -> String

def Mbox.addrs source · line 101 · raw

@ms:List<&2, Mbox> -> List<&2, String>

def Mbox.all.ok source · line 108 · raw

@ms:List<&2, Mbox> -> Bool

def Mbox.bad source · line 116 · raw

@ms:List<&2, Mbox> -> String

The first bad address of a list, or "" when all are good.

def Mbox.any.utf8 source · line 125 · raw

@ms:List<&2, Mbox> -> Bool

def Mbox.ascii source · line 132 · raw

@m:Mbox -> Mbox

def Mbox.asciis source · line 136 · raw

@ms:List<&2, Mbox> -> List<&2, Mbox>

def Mbox.flush source · line 151 · raw

@cur:String -> @acc:List<&2, String> -> List<&2, String>

def Mbox.cut.ch source · line 154 · raw

@st:Cut -> @+c:U32 -> Cut

def Mbox.cut.go source · line 166 · raw

@s:String -> @st:Cut -> Cut

def Mbox.keep source · line 173 · raw

@empty:Bool -> @x:String -> @rest:List<&2, String> -> List<&2, String>

def Mbox.nonempty source · line 180 · raw

@xs:List<&2, String> -> List<&2, String>

def Mbox.cut.fin source · line 187 · raw

@st:Cut -> List<&2, String>

def Mbox.items source · line 192 · raw

@s:String -> List<&2, String>

The items of a comma-separated list; commas in quotes or <...> stay.

def Mbox.unescape source · line 195 · raw

@s:String -> String

def Mbox.unquote source · line 205 · raw

@+s:String -> String

A display name as written: its quotes taken off.

def Mbox.head source · line 210 · raw

@xs:List<&2, String> -> String

def Mbox.angled source · line 217 · raw

@+parts:List<&2, String> -> Mbox

def Mbox.parse.at source · line 223 · raw

@plain:Bool -> @item:String -> Mbox

def Mbox.parse source · line 231 · raw

@+item:String -> Mbox

One mailbox: "name <addr>", "<addr>" or "addr".

def Mbox.parses source · line 234 · raw

@xs:List<&2, String> -> List<&2, Mbox>

def Mbox.list source · line 242 · raw

@s:String -> List<&2, Mbox>

The mailboxes of a list as people write it.

def Mbox.atoms source · line 248 · raw

@s:String -> Bool

def Mbox.esc source · line 255 · raw

@yes:Bool -> @c:U32 -> @rest:String -> String

def Mbox.quote source · line 262 · raw

@s:String -> String

def Mbox.phrase source · line 272 · raw

@+s:String -> String

A display name as a phrase (RFC 5322 3.2.5): atoms as they are, other printable ASCII as a quoted string, the rest (and anything that could read as an encoded word) as RFC 2047 words.

def Mbox.show.at source · line 277 · raw

@none:Bool -> @name:String -> @addr:String -> String

def Mbox.show source · line 285 · raw

@m:Mbox -> String

A mailbox in a header: "name <addr>", or the bare address.

def Mbox.shows.more source · line 290 · raw

@ms:List<&2, Mbox> -> String

def Mbox.shows source · line 298 · raw

@ms:List<&2, Mbox> -> String

A list header's value: one mailbox per (folded) line.