The AddressParser class helps parse email addresses and lists.
In the interests of simplicity, AddressParser parses everything as if it were a list of addresses - either of the mailbox-list or address-list productions in RFC 2822. The user of this class must check that the supplied addresses fit the (often more specific) requirements.
AddressParser supports most of RFC 822 and 2822, but mostly omits address groups. An empty address group is translated into a single Address, a nonempty group is translated into the equivalent number of addresses.
AddressParser does not attempt to canonicalize the addresses parsed or get rid of duplicates (To: email@example.com, firstname.lastname@example.org), it only parses.
The first error seen is stored and can be accessed using error().
This private helper adds the address with name, localpart and domain to the list, unless it's there already.
name is adjusted heuristically.
This version of add() uses only localpart and domain.
This private function parses an address ending at position i and adds it to the list.
Returns a pointer to the addresses parsed. The pointer remains valid until this object is deleted.
This private function parses and returns the atom ending at i.
This very private helper helps comment() handle nested comments. It advances i to the start of a comment (where it points to '(').
This private function skips past a sequence of spaces and comments at i, or past nothing. Nothing is perfectly okay.
This private function picks up a domain ending at i and returns it as a string. The validity of the domain is not checked (and should not be - it may come from an old mail message) only its syntactical validity.
This private function records the error s, which is considered to occur at position i.
The name error() is overloaded, nastily. But I don't feel like fixing that right now.
Returns the first error detected (and not compensated) this parser.
Finds the point between left and right which is most likely to be the border between two addresses. Mucho heuristics. Never used for correct addresses, only when we're grasping at straws.
Both left and right are considered to be possible borders, but a border between the extremes is preferred if possible.
This private function parses the localpart ending at i, and returns it as a string.
This private function parses an RFC 2822 phrase (a sequence of words, more or less) ending at i, and returns the phrase as a string.
This static function parses the references field r. This is in AddressParser because References and Message-ID both use the address productions in RFC 822/1034.
This function does it best to skip ahead to the next message-id if there is a syntax error in one. It silently ignores the errors. This is because it's so common to have a bad message-id in the references field of an otherwise impeccable message.
If i points to an obs-route, this function silently skips the route.
This private function skips past space at position i, or past nothing. Nothing is perfectly okay.
This static helper removes quoted-pair from s and turns all sequences of spaces into a single space. It returns the result.
This web page based on source code belonging to The Archiveopteryx Developers. All rights reserved.