TYPO3 CMS  TYPO3_6-2
TYPO3\CMS\Core\Mail\Rfc822AddressesParser Class Reference
Inheritance diagram for TYPO3\CMS\Core\Mail\Rfc822AddressesParser:
t3lib_mail_Rfc822AddressesParser

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 70 of file Rfc822AddressesParser.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Mail\Rfc822AddressesParser::__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.
boolean$validateWhether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance.

Definition at line 144 of file Rfc822AddressesParser.php.

References TYPO3\CMS\Core\Mail\Rfc822AddressesParser\$address, TYPO3\CMS\Core\Mail\Rfc822AddressesParser\$default_domain, TYPO3\CMS\Core\Mail\Rfc822AddressesParser\$limit, and TYPO3\CMS\Core\Mail\Rfc822AddressesParser\$validate.

Member Function Documentation

◆ _hasUnclosedBrackets()

TYPO3\CMS\Core\Mail\Rfc822AddressesParser::_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
boolean TRUE if there are unclosed brackets inside the string, FALSE otherwise.

Definition at line 356 of file Rfc822AddressesParser.php.

References TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_hasUnclosedBracketsSub().

Referenced by TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_splitCheck().

◆ _hasUnclosedBracketsSub()

TYPO3\CMS\Core\Mail\Rfc822AddressesParser::_hasUnclosedBracketsSub (   $string,
$num,
  $char 
)
protected

Sub function that is used only by hasUnclosedBrackets().

private

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

Definition at line 378 of file Rfc822AddressesParser.php.

References TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_hasUnclosedQuotes().

Referenced by TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_hasUnclosedBrackets().

◆ _hasUnclosedQuotes()

TYPO3\CMS\Core\Mail\Rfc822AddressesParser::_hasUnclosedQuotes (   $string)
protected

Checks if a string has unclosed quotes or not.

private

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

Definition at line 326 of file Rfc822AddressesParser.php.

Referenced by TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_hasUnclosedBracketsSub(), and TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_splitCheck().

◆ _isGroup()

TYPO3\CMS\Core\Mail\Rfc822AddressesParser::_isGroup (   $address)
protected

Checks for a group at the start of the string.

private

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

Definition at line 277 of file Rfc822AddressesParser.php.

References TYPO3\CMS\Core\Mail\Rfc822AddressesParser\$address, and TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_splitCheck().

Referenced by TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_splitAddresses().

◆ _splitAddresses()

TYPO3\CMS\Core\Mail\Rfc822AddressesParser::_splitAddresses (   $address)
protected

Splits an address into separate addresses.

private

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

Definition at line 216 of file Rfc822AddressesParser.php.

References TYPO3\CMS\Core\Mail\Rfc822AddressesParser\$address, TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_isGroup(), and TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_splitCheck().

Referenced by TYPO3\CMS\Core\Mail\Rfc822AddressesParser\parseAddressList().

◆ _splitCheck()

◆ _validateAddress()

TYPO3\CMS\Core\Mail\Rfc822AddressesParser::_validateAddress (   $address)
protected

◆ _validateAddrSpec()

TYPO3\CMS\Core\Mail\Rfc822AddressesParser::_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 748 of file Rfc822AddressesParser.php.

References TYPO3\CMS\Core\Mail\Rfc822AddressesParser\$default_domain, TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_splitCheck(), TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_validateDomain(), and TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_validateLocalPart().

Referenced by TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_validateRouteAddr(), and TYPO3\CMS\Core\Mail\Rfc822AddressesParser\validateMailbox().

◆ _validateAtom()

TYPO3\CMS\Core\Mail\Rfc822AddressesParser::_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
boolean Success or failure.

Definition at line 503 of file Rfc822AddressesParser.php.

Referenced by TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_validatePhrase(), and TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_validateSubdomain().

◆ _validateDliteral()

TYPO3\CMS\Core\Mail\Rfc822AddressesParser::_validateDliteral (   $dliteral)
protected

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

private

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

Definition at line 735 of file Rfc822AddressesParser.php.

Referenced by TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_validateSubdomain().

◆ _validateDomain()

TYPO3\CMS\Core\Mail\Rfc822AddressesParser::_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 687 of file Rfc822AddressesParser.php.

References TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_splitCheck(), and TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_validateSubdomain().

Referenced by TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_validateAddrSpec(), and TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_validateRoute().

◆ _validateLocalPart()

TYPO3\CMS\Core\Mail\Rfc822AddressesParser::_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 777 of file Rfc822AddressesParser.php.

References TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_splitCheck(), and TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_validatePhrase().

Referenced by TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_validateAddrSpec().

◆ _validatePhrase()

TYPO3\CMS\Core\Mail\Rfc822AddressesParser::_validatePhrase (   $phrase)
protected

◆ _validateQuotedString()

TYPO3\CMS\Core\Mail\Rfc822AddressesParser::_validateQuotedString (   $qstring)
protected

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

private

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

Definition at line 531 of file Rfc822AddressesParser.php.

Referenced by TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_validatePhrase().

◆ _validateRoute()

TYPO3\CMS\Core\Mail\Rfc822AddressesParser::_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 665 of file Rfc822AddressesParser.php.

References TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_validateDomain().

Referenced by TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_validateRouteAddr().

◆ _validateRouteAddr()

TYPO3\CMS\Core\Mail\Rfc822AddressesParser::_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 621 of file Rfc822AddressesParser.php.

References TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_splitCheck(), TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_validateAddrSpec(), and TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_validateRoute().

Referenced by TYPO3\CMS\Core\Mail\Rfc822AddressesParser\validateMailbox().

◆ _validateSubdomain()

TYPO3\CMS\Core\Mail\Rfc822AddressesParser::_validateSubdomain (   $subdomain)
protected

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

private

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

Definition at line 713 of file Rfc822AddressesParser.php.

References TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_validateAtom(), and TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_validateDliteral().

Referenced by TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_validateDomain().

◆ parseAddressList()

TYPO3\CMS\Core\Mail\Rfc822AddressesParser::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.
boolean$nest_groupsWhether to return the structure with groups nested for easier viewing.
boolean$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 170 of file Rfc822AddressesParser.php.

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

◆ validateMailbox()

TYPO3\CMS\Core\Mail\Rfc822AddressesParser::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
boolean Success or failure.

Definition at line 547 of file Rfc822AddressesParser.php.

References TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_splitCheck(), TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_validateAddrSpec(), TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_validatePhrase(), and TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_validateRouteAddr().

Referenced by TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_validateAddress().

Member Data Documentation

◆ $address

◆ $addresses

array TYPO3\CMS\Core\Mail\Rfc822AddressesParser::$addresses = array()
private

The array of raw addresses built up as we parse.

Definition at line 98 of file Rfc822AddressesParser.php.

Referenced by TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_validateAddress().

◆ $default_domain

string TYPO3\CMS\Core\Mail\Rfc822AddressesParser::$default_domain = 'localhost'
private

◆ $error

string TYPO3\CMS\Core\Mail\Rfc822AddressesParser::$error = NULL
private

The current error message, if any.

Definition at line 112 of file Rfc822AddressesParser.php.

◆ $index

integer TYPO3\CMS\Core\Mail\Rfc822AddressesParser::$index = NULL
private

An internal counter/pointer.

Definition at line 119 of file Rfc822AddressesParser.php.

◆ $limit

int TYPO3\CMS\Core\Mail\Rfc822AddressesParser::$limit = NULL
private

◆ $num_groups

integer TYPO3\CMS\Core\Mail\Rfc822AddressesParser::$num_groups = 0
private

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

public

Definition at line 127 of file Rfc822AddressesParser.php.

◆ $structure

array TYPO3\CMS\Core\Mail\Rfc822AddressesParser::$structure = array()
private

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

Definition at line 105 of file Rfc822AddressesParser.php.

Referenced by TYPO3\CMS\Core\Mail\Rfc822AddressesParser\_validateAddress(), and TYPO3\CMS\Core\Mail\Rfc822AddressesParser\parseAddressList().

◆ $validate

boolean TYPO3\CMS\Core\Mail\Rfc822AddressesParser::$validate = TRUE
private

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

Definition at line 91 of file Rfc822AddressesParser.php.

Referenced by TYPO3\CMS\Core\Mail\Rfc822AddressesParser\__construct(), and TYPO3\CMS\Core\Mail\Rfc822AddressesParser\parseAddressList().