TYPO3  7.6
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
Rfc822AddressesParser Class Reference

Public Member Functions

 __construct ($address=null, $default_domain=null, $validate=null, $limit=null)
 
 parseAddressList ($address=null, $default_domain=null, $validate=null, $limit=null)
 

Protected Member Functions

 _splitAddresses ($address)
 
 _isGroup ($address)
 
 _splitCheck ($parts, $char)
 
 _hasUnclosedQuotes ($string)
 
 _hasUnclosedBrackets ($string, $chars)
 
 _hasUnclosedBracketsSub ($string, &$num, $char)
 
 _validateAddress ($address)
 
 _validatePhrase ($phrase)
 
 _validateAtom ($atom)
 
 _validateQuotedString ($qstring)
 
 validateMailbox (&$mailbox)
 
 _validateRouteAddr ($route_addr)
 
 _validateRoute ($route)
 
 _validateDomain ($domain)
 
 _validateSubdomain ($subdomain)
 
 _validateDliteral ($dliteral)
 
 _validateAddrSpec ($addr_spec)
 
 _validateLocalPart ($local_part)
 

Private Attributes

 $address = ''
 
 $default_domain = 'localhost'
 
 $validate = true
 
 $addresses = array()
 
 $structure = array()
 
 $error = null
 
 $index = null
 
 $num_groups = 0
 
 $limit = null
 

Detailed Description

Definition at line 65 of file Rfc822AddressesParser.php.

Constructor & Destructor Documentation

__construct (   $address = null,
  $default_domain = null,
  $validate = null,
  $limit = null 
)

Sets up the object.

public

Parameters
string$addressThe address(es) to validate.
string$default_domainDefault domain/host etc. If not supplied, will be set to localhost.
bool$validateWhether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance.

Definition at line 139 of file Rfc822AddressesParser.php.

References Rfc822AddressesParser\$address, Rfc822AddressesParser\$default_domain, Rfc822AddressesParser\$limit, and Rfc822AddressesParser\$validate.

Member Function Documentation

_hasUnclosedBrackets (   $string,
  $chars 
)
protected

Checks if a string has an unclosed brackets or not. IMPORTANT: This function handles both angle brackets and square brackets;

private

Parameters
string$stringThe string to check.
string$charsThe characters to check for.
Returns
bool TRUE if there are unclosed brackets inside the string, FALSE otherwise.

Definition at line 356 of file Rfc822AddressesParser.php.

References Rfc822AddressesParser\_hasUnclosedBracketsSub().

Referenced by Rfc822AddressesParser\_splitCheck().

_hasUnclosedBracketsSub (   $string,
$num,
  $char 
)
protected

Sub function that is used only by hasUnclosedBrackets().

private

Parameters
string$stringThe string to check.
int&$numThe number of occurrences.
string$charThe character to count.
Returns
int The number of occurrences of $char in $string, adjusted for backslashes.

Definition at line 379 of file Rfc822AddressesParser.php.

References Rfc822AddressesParser\_hasUnclosedQuotes().

Referenced by Rfc822AddressesParser\_hasUnclosedBrackets().

_hasUnclosedQuotes (   $string)
protected

Checks if a string has unclosed quotes or not.

private

Parameters
string$stringThe string to check.
Returns
bool TRUE if there are unclosed quotes inside the string,

Definition at line 325 of file Rfc822AddressesParser.php.

Referenced by Rfc822AddressesParser\_hasUnclosedBracketsSub(), and Rfc822AddressesParser\_splitCheck().

_isGroup (   $address)
protected

Checks for a group at the start of the string.

private

Parameters
string$addressThe address to check.
Returns
bool Whether or not there is a group at the start of the string.

Definition at line 274 of file Rfc822AddressesParser.php.

References Rfc822AddressesParser\$address, and Rfc822AddressesParser\_splitCheck().

Referenced by Rfc822AddressesParser\_splitAddresses().

_splitAddresses (   $address)
protected

Splits an address into separate addresses.

private

Parameters
string$addressThe addresses to split.
Returns
bool Success or failure.

Definition at line 212 of file Rfc822AddressesParser.php.

References Rfc822AddressesParser\$address, Rfc822AddressesParser\_isGroup(), Rfc822AddressesParser\_splitCheck(), and elseif.

Referenced by Rfc822AddressesParser\parseAddressList().

_splitCheck (   $parts,
  $char 
)
protected

A common function that will check an exploded string.

private

Parameters
array$partsThe exloded string.
string$charThe char that was exploded on.
Returns
mixed False if the string contains unclosed quotes/brackets, or the string on success.

Definition at line 298 of file Rfc822AddressesParser.php.

References Rfc822AddressesParser\_hasUnclosedBrackets(), and Rfc822AddressesParser\_hasUnclosedQuotes().

Referenced by Rfc822AddressesParser\_isGroup(), Rfc822AddressesParser\_splitAddresses(), Rfc822AddressesParser\_validateAddress(), Rfc822AddressesParser\_validateAddrSpec(), Rfc822AddressesParser\_validateDomain(), Rfc822AddressesParser\_validateLocalPart(), Rfc822AddressesParser\_validatePhrase(), Rfc822AddressesParser\_validateRouteAddr(), and Rfc822AddressesParser\validateMailbox().

_validateAddress (   $address)
protected

Function to begin checking the address.

private

Parameters
string$addressThe address to validate.
Returns
mixed False on failure, or a structured array of address information on success.

Definition at line 401 of file Rfc822AddressesParser.php.

References Rfc822AddressesParser\$address, Rfc822AddressesParser\$addresses, Rfc822AddressesParser\$structure, Rfc822AddressesParser\_splitCheck(), Rfc822AddressesParser\_validatePhrase(), and Rfc822AddressesParser\validateMailbox().

Referenced by Rfc822AddressesParser\parseAddressList().

_validateAddrSpec (   $addr_spec)
protected

Function to validate an addr-spec.

addr-spec = local-part "@" domain

private

Parameters
string$addr_specThe string to check.
Returns
mixed False on failure, or the validated addr-spec on success.

Definition at line 760 of file Rfc822AddressesParser.php.

References Rfc822AddressesParser\$default_domain, Rfc822AddressesParser\_splitCheck(), Rfc822AddressesParser\_validateDomain(), and Rfc822AddressesParser\_validateLocalPart().

Referenced by Rfc822AddressesParser\_validateRouteAddr(), and Rfc822AddressesParser\validateMailbox().

_validateAtom (   $atom)
protected

Function to validate an atom which from rfc822 is: atom = 1*<any CHAR except specials, SPACE and CTLs>

If validation ($this->validate) has been turned off, then validateAtom() doesn't actually check anything. This is so that you can split a list of addresses up before encoding personal names (umlauts, etc.), for example.

private

Parameters
string$atomThe string to check.
Returns
bool Success or failure.

Definition at line 507 of file Rfc822AddressesParser.php.

Referenced by Rfc822AddressesParser\_validatePhrase(), and Rfc822AddressesParser\_validateSubdomain().

_validateDliteral (   $dliteral)
protected

Function to validate a domain literal: domain-literal = "[" *(dtext / quoted-pair) "]"

private

Parameters
string$dliteralThe string to check.
Returns
bool Success or failure.

Definition at line 746 of file Rfc822AddressesParser.php.

Referenced by Rfc822AddressesParser\_validateSubdomain().

_validateDomain (   $domain)
protected

Function to validate a domain, though this is not quite what you expect of a strict internet domain.

domain = sub-domain *("." sub-domain)

private

Parameters
string$domainThe string to check.
Returns
mixed False on failure, or the validated domain on success.

Definition at line 696 of file Rfc822AddressesParser.php.

References Rfc822AddressesParser\_splitCheck(), and Rfc822AddressesParser\_validateSubdomain().

Referenced by Rfc822AddressesParser\_validateAddrSpec(), and Rfc822AddressesParser\_validateRoute().

_validateLocalPart (   $local_part)
protected

Function to validate the local part of an address: local-part = word *("." word)

private

Parameters
string$local_part
Returns
mixed False on failure, or the validated local part on success.

Definition at line 790 of file Rfc822AddressesParser.php.

References Rfc822AddressesParser\_splitCheck(), and Rfc822AddressesParser\_validatePhrase().

Referenced by Rfc822AddressesParser\_validateAddrSpec().

_validatePhrase (   $phrase)
protected

Function to validate a phrase.

private

Parameters
string$phraseThe phrase to check.
Returns
bool Success or failure.

Definition at line 467 of file Rfc822AddressesParser.php.

References Rfc822AddressesParser\_splitCheck(), Rfc822AddressesParser\_validateAtom(), and Rfc822AddressesParser\_validateQuotedString().

Referenced by Rfc822AddressesParser\_validateAddress(), Rfc822AddressesParser\_validateLocalPart(), and Rfc822AddressesParser\validateMailbox().

_validateQuotedString (   $qstring)
protected

Function to validate quoted string, which is: quoted-string = <"> *(qtext/quoted-pair) <">

private

Parameters
string$qstringThe string to check
Returns
bool Success or failure.

Definition at line 536 of file Rfc822AddressesParser.php.

Referenced by Rfc822AddressesParser\_validatePhrase().

_validateRoute (   $route)
protected

Function to validate a route, which is: route = 1#("@" domain) ":"

private

Parameters
string$routeThe string to check.
Returns
mixed False on failure, or the validated $route on success.

Definition at line 673 of file Rfc822AddressesParser.php.

References Rfc822AddressesParser\_validateDomain().

Referenced by Rfc822AddressesParser\_validateRouteAddr().

_validateRouteAddr (   $route_addr)
protected

This function validates a route-addr which is: route-addr = "<" [route] addr-spec ">"

Angle brackets have already been removed at the point of getting to this function.

private

Parameters
string$route_addrThe string to check.
Returns
mixed False on failure, or an array containing validated address/route information on success.

Definition at line 628 of file Rfc822AddressesParser.php.

References Rfc822AddressesParser\_splitCheck(), Rfc822AddressesParser\_validateAddrSpec(), and Rfc822AddressesParser\_validateRoute().

Referenced by Rfc822AddressesParser\validateMailbox().

_validateSubdomain (   $subdomain)
protected

Function to validate a subdomain: subdomain = domain-ref / domain-literal

private

Parameters
string$subdomainThe string to check.
Returns
bool Success or failure.

Definition at line 723 of file Rfc822AddressesParser.php.

References Rfc822AddressesParser\_validateAtom(), and Rfc822AddressesParser\_validateDliteral().

Referenced by Rfc822AddressesParser\_validateDomain().

parseAddressList (   $address = null,
  $default_domain = null,
  $validate = null,
  $limit = null 
)

Starts the whole process. The address must either be set here or when creating the object. One or the other.

public

Parameters
string$addressThe address(es) to validate.
string$default_domainDefault domain/host etc.
bool$nest_groupsWhether to return the structure with groups nested for easier viewing.
bool$validateWhether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance.
Returns
array A structured array of addresses.

Definition at line 166 of file Rfc822AddressesParser.php.

References Rfc822AddressesParser\$address, Rfc822AddressesParser\$default_domain, Rfc822AddressesParser\$limit, Rfc822AddressesParser\$structure, Rfc822AddressesParser\$validate, Rfc822AddressesParser\_splitAddresses(), and Rfc822AddressesParser\_validateAddress().

validateMailbox ( $mailbox)
protected

Function to validate a mailbox, which is: mailbox = addr-spec ; simple address phrase route-addr ; name and route-addr

public

Parameters
string&$mailboxThe string to check.
Returns
bool Success or failure.

Definition at line 553 of file Rfc822AddressesParser.php.

References Rfc822AddressesParser\_splitCheck(), Rfc822AddressesParser\_validateAddrSpec(), Rfc822AddressesParser\_validatePhrase(), and Rfc822AddressesParser\_validateRouteAddr().

Referenced by Rfc822AddressesParser\_validateAddress().

Member Data Documentation

string $address = ''
private
array $addresses = array()
private

The array of raw addresses built up as we parse.

Definition at line 93 of file Rfc822AddressesParser.php.

Referenced by Rfc822AddressesParser\_validateAddress().

string $default_domain = 'localhost'
private

The default domain to use for unqualified addresses.

Definition at line 79 of file Rfc822AddressesParser.php.

Referenced by Rfc822AddressesParser\__construct(), Rfc822AddressesParser\_validateAddrSpec(), and Rfc822AddressesParser\parseAddressList().

string $error = null
private

The current error message, if any.

Definition at line 107 of file Rfc822AddressesParser.php.

int $index = null
private

An internal counter/pointer.

Definition at line 114 of file Rfc822AddressesParser.php.

int $limit = null
private

A limit after which processing stops

Definition at line 129 of file Rfc822AddressesParser.php.

Referenced by Rfc822AddressesParser\__construct(), and Rfc822AddressesParser\parseAddressList().

int $num_groups = 0
private

The number of groups that have been found in the address list.

public

Definition at line 122 of file Rfc822AddressesParser.php.

array $structure = array()
private

The final array of parsed address information that we build up.

Definition at line 100 of file Rfc822AddressesParser.php.

Referenced by Rfc822AddressesParser\_validateAddress(), and Rfc822AddressesParser\parseAddressList().

bool $validate = true
private

Whether or not to validate atoms for non-ascii characters.

Definition at line 86 of file Rfc822AddressesParser.php.

Referenced by Rfc822AddressesParser\__construct(), and Rfc822AddressesParser\parseAddressList().