ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
RFC822.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
92 {
97  public string $address = '';
98 
103  public string $default_domain = 'localhost';
104 
109  public bool $nestGroups = true;
110 
115  public bool $validate = true;
116 
121  public array $addresses = [];
122 
127  public array $structure = [];
128 
133  public ?string $error = null;
134 
139  public ?int $index = null;
140 
146  public int $num_groups = 0;
147 
153  public bool $mailRFC822 = true;
154 
159  public ?int $limit = null;
160 
171  public function __construct(
172  string $address = null,
173  string $default_domain = null,
174  bool $nest_groups = null,
175  bool $validate = null,
176  int $limit = null
177  ) {
178  if (isset($address)) {
179  $this->address = $address;
180  }
181  if (isset($default_domain)) {
182  $this->default_domain = $default_domain;
183  }
184  if (isset($nest_groups)) {
185  $this->nestGroups = $nest_groups;
186  }
187  if (isset($validate)) {
188  $this->validate = $validate;
189  }
190  if (isset($limit)) {
191  $this->limit = $limit;
192  }
193  }
194 
206  public function parseAddressList(
207  string $address = null,
208  string $default_domain = null,
209  bool $nest_groups = null,
210  bool $validate = null,
211  int $limit = null
212  ): array {
213  if (!isset($this, $this->mailRFC822)) {
214  $obj = new Mail_RFC822($address, $default_domain, $nest_groups, $validate, $limit);
215  return $obj->parseAddressList();
216  }
217 
218  if (isset($address)) {
219  $this->address = $address;
220  }
221  if (isset($default_domain)) {
222  $this->default_domain = $default_domain;
223  }
224  if (isset($nest_groups)) {
225  $this->nestGroups = $nest_groups;
226  }
227  if (isset($validate)) {
228  $this->validate = $validate;
229  }
230  if (isset($limit)) {
231  $this->limit = $limit;
232  }
233 
234  $this->structure = [];
235  $this->addresses = [];
236  $this->error = null;
237  $this->index = null;
238 
239  // Unfold any long lines in $this->address.
240  $this->address = preg_replace('/\r?\n/', "\r\n", $this->address);
241  $this->address = preg_replace('/\r\n(\t| )+/', ' ', $this->address);
242 
243  $tmp_address = false;
244  while ($tmp_address = $this->_splitAddresses($this->address)) {
245  $this->address = $tmp_address;
246  }
247 
248  if ($tmp_address === false || isset($this->error)) {
249  // mjansen patch 14 Ap 2016 start
250  throw new ilMailException($this->error);
251  // mjansen patch 14 Ap 2016 end
252  }
253 
254  // Validate each address individually. If we encounter an invalid
255  // address, stop iterating and return an error immediately.
256  foreach ($this->addresses as $address) {
257  $valid = $this->_validateAddress($address);
258 
259  if ($valid === false || isset($this->error)) {
260  // mjansen patch 14 Ap 2016 start
261  throw new ilMailException($this->error);
262  // mjansen patch 14 Ap 2016 end
263  }
264 
265  if (!$this->nestGroups) {
266  $this->structure = array_merge($this->structure, $valid);
267  } else {
268  $this->structure[] = $valid;
269  }
270  }
271 
272  return $this->structure;
273  }
274 
281  protected function _splitAddresses(string $address)
282  {
283  if (!empty($this->limit) && count($this->addresses) === $this->limit) {
284  return false;
285  }
286 
287  if (!isset($this->error) && $this->_isGroup($address)) {
288  $split_char = ';';
289  $is_group = true;
290  } elseif (!isset($this->error)) {
291  $split_char = ',';
292  $is_group = false;
293  } elseif (isset($this->error)) {
294  return false;
295  }
296 
297  // Split the string based on the above ten or so lines.
298  $parts = explode($split_char, $address);
299  $string = $this->_splitCheck($parts, $split_char);
300 
301  // If a group...
302  if ($is_group) {
303  // If $string does not contain a colon outside of
304  // brackets/quotes etc then something's fubar.
305 
306  // First check there's a colon at all:
307  if (strpos($string, ':') === false) {
308  $this->error = 'Invalid address: ' . $string;
309  return false;
310  }
311 
312  // Now check it's outside of brackets/quotes:
313  if (!$this->_splitCheck(explode(':', $string), ':')) {
314  return false;
315  }
316 
317  // We must have a group at this point, so increase the counter:
318  $this->num_groups++;
319  }
320 
321  // $string now contains the first full address/group.
322  // Add to the addresses array.
323  $this->addresses[] = [
324  'address' => trim($string),
325  'group' => $is_group,
326  ];
327 
328  // Remove the now stored address from the initial line, the +1
329  // is to account for the explode character.
330  $address = trim((string) substr($address, strlen($string) + 1));
331 
332  // If the next char is a comma and this was a group, then
333  // there are more addresses, otherwise, if there are any more
334  // chars, then there is another address.
335  if ($is_group && $address[0] === ',') {
336  $address = trim(substr($address, 1));
337  return $address;
338  }
339 
340  return $address;
341  }
342 
349  protected function _isGroup(string $address): bool
350  {
351  // First comma not in quotes, angles or escaped:
352  $parts = explode(',', $address);
353  $string = $this->_splitCheck($parts, ',');
354 
355  // Now we have the first address, we can reliably check for a
356  // group by searching for a colon that's not escaped or in
357  // quotes or angle brackets.
358  if (count($parts = explode(':', $string)) > 1) {
359  $string2 = $this->_splitCheck($parts, ':');
360  return ($string2 !== $string);
361  }
362 
363  return false;
364  }
365 
373  protected function _splitCheck(array $parts, string $char): string
374  {
375  $string = $parts[0];
376 
377  for ($i = 0, $iMax = count($parts); $i < $iMax; $i++) {
378  if ($this->_hasUnclosedQuotes($string)
379  || $this->_hasUnclosedBrackets($string, '<>')
380  || $this->_hasUnclosedBrackets($string, '[]')
381  || $this->_hasUnclosedBrackets($string, '()')
382  || substr($string, -1) === '\\') {
383  if (isset($parts[$i + 1])) {
384  $string .= $char . $parts[$i + 1];
385  } else {
386  $this->error = 'Invalid address spec. Unclosed bracket or quotes';
387  return '';
388  }
389  } else {
390  $this->index = $i;
391  break;
392  }
393  }
394 
395  return $string;
396  }
397 
404  protected function _hasUnclosedQuotes(string $string): bool
405  {
406  $string = trim($string);
407  $iMax = strlen($string);
408  $in_quote = false;
409  $i = $slashes = 0;
410 
411  for (; $i < $iMax; ++$i) {
412  switch ($string[$i]) {
413  case '\\':
414  ++$slashes;
415  break;
416 
417  case '"':
418  if ($slashes % 2 === 0) {
419  $in_quote = !$in_quote;
420  }
421  // Fall through to default action below.
422 
423  // no break
424  default:
425  $slashes = 0;
426  break;
427  }
428  }
429 
430  return $in_quote;
431  }
432 
441  protected function _hasUnclosedBrackets(string $string, string $chars): bool
442  {
443  $num_angle_start = substr_count($string, $chars[0]);
444  $num_angle_end = substr_count($string, $chars[1]);
445 
446  $this->_hasUnclosedBracketsSub($string, $num_angle_start, $chars[0]);
447  $this->_hasUnclosedBracketsSub($string, $num_angle_end, $chars[1]);
448 
449  if ($num_angle_start < $num_angle_end) {
450  $this->error = 'Invalid address spec. Unmatched quote or bracket (' . $chars . ')';
451  return false;
452  }
453 
454  return ($num_angle_start > $num_angle_end);
455  }
456 
465  protected function _hasUnclosedBracketsSub(string $string, int &$num, string $char): int
466  {
467  $parts = explode($char, $string);
468  for ($i = 0, $iMax = count($parts); $i < $iMax; $i++) {
469  if (substr($parts[$i], -1) === '\\' || $this->_hasUnclosedQuotes($parts[$i])) {
470  $num--;
471  }
472  if (isset($parts[$i + 1])) {
473  $parts[$i + 1] = $parts[$i] . $char . $parts[$i + 1];
474  }
475  }
476 
477  return $num;
478  }
479 
486  protected function _validateAddress(array $address)
487  {
488  $is_group = false;
489  $addresses = [];
490 
491  if ($address['group']) {
492  $is_group = true;
493 
494  // Get the group part of the name
495  $parts = explode(':', $address['address']);
496  $groupname = $this->_splitCheck($parts, ':');
497  $structure = [];
498 
499  // And validate the group part of the name.
500  if (!$this->_validatePhrase($groupname)) {
501  $this->error = 'Group name did not validate.';
502  return false;
503  }
504 
505  if ($this->nestGroups) {
506  // Don't include groups if we are not nesting
507  // them. This avoids returning invalid addresses.
508  $structure = new stdClass();
509  $structure->groupname = $groupname;
510  }
511 
512  $address['address'] = ltrim(substr($address['address'], strlen($groupname . ':')));
513  }
514 
515  // If a group then split on comma and put into an array.
516  // Otherwise, Just put the whole address in an array.
517  if ($is_group) {
518  while (strlen($address['address']) > 0) {
519  $parts = explode(',', $address['address']);
520  $addresses[] = $this->_splitCheck($parts, ',');
521  $address['address'] = trim(substr($address['address'], strlen(end($addresses) . ',')));
522  }
523  } else {
524  $addresses[] = $address['address'];
525  }
526 
527  // Trim the whitespace from all of the address strings.
528  array_map('trim', $addresses);
529 
530  // Validate each mailbox.
531  // Format could be one of: name <geezer@domain.com>
532  // geezer@domain.com
533  // geezer
534  // ... or any other format valid by RFC 822.
535  for ($i = 0, $iMax = count($addresses); $i < $iMax; $i++) {
536  if (!$this->validateMailbox($addresses[$i])) {
537  if (empty($this->error)) {
538  $this->error = 'Validation failed for: ' . $addresses[$i];
539  }
540  return false;
541  }
542  }
543 
544  // Nested format
545  if ($this->nestGroups) {
546  if ($is_group) {
547  $structure->addresses = $addresses;
548  } else {
549  $structure = $addresses[0];
550  }
551 
552  // Flat format
553  } elseif ($is_group) {
554  $structure = array_merge($structure, $addresses);
555  } else {
556  $structure = $addresses;
557  }
558 
559  return $structure;
560  }
561 
568  protected function _validatePhrase(string $phrase): bool
569  {
570  // Splits on one or more Tab or space.
571  $parts = preg_split('/[ \\x09]+/', $phrase, -1, PREG_SPLIT_NO_EMPTY);
572 
573  $phrase_parts = [];
574  while (count($parts) > 0) {
575  $phrase_parts[] = $this->_splitCheck($parts, ' ');
576  for ($i = 0; $i < $this->index + 1; $i++) {
577  array_shift($parts);
578  }
579  }
580 
581  foreach ($phrase_parts as $part) {
582  // If quoted string:
583  if (strpos($part, '"') === 0) {
584  if (!$this->_validateQuotedString($part)) {
585  return false;
586  }
587  continue;
588  }
589 
590  // Otherwise it's an atom:
591  if (!$this->_validateAtom($part)) {
592  return false;
593  }
594  }
595 
596  return true;
597  }
598 
611  protected function _validateAtom(string $atom): bool
612  {
613  if (!$this->validate) {
614  // Validation has been turned off; assume the atom is okay.
615  return true;
616  }
617 
618  // Check for any char from ASCII 0 - ASCII 127
619  // mjansen patch 16 Sep 2015 start
620  // Check for specials:
621  if (preg_match('/[][()<>@,;\\:". ]/', $atom)) {
622  return false;
623  }
624 
625  // Check for control characters (ASCII 0-31):
626  if (preg_match('/[\\x00-\\x1F]+/', $atom)) {
627  return false;
628  }
629  #16291
630  #17618
631  if (!(bool) preg_match('//u', $atom)) {
632  return false;
633  }
634  // mjansen patch 16 Sep 2015 end
635 
636  return true;
637  }
638 
646  protected function _validateQuotedString(string $qstring): bool
647  {
648  // Leading and trailing "
649  $qstring = substr($qstring, 1, -1);
650 
651  // Perform check, removing quoted characters first.
652  return !preg_match('/[\x0D\\\\"]/', preg_replace('/\\\\./', '', $qstring));
653  }
654 
663  public function validateMailbox(string &$mailbox): bool
664  {
665  // A couple of defaults.
666  $phrase = '';
667  $comment = '';
668  $comments = [];
669 
670  // Catch any RFC822 comments and store them separately.
671  $_mailbox = $mailbox;
672  while (trim($_mailbox) !== '') {
673  $parts = explode('(', $_mailbox);
674  $before_comment = $this->_splitCheck($parts, '(');
675  if ($before_comment !== $_mailbox) {
676  // First char should be a (.
677  $comment = substr(str_replace($before_comment, '', $_mailbox), 1);
678  $parts = explode(')', $comment);
679  $comment = $this->_splitCheck($parts, ')');
680  $comments[] = $comment;
681 
682  // +2 is for the brackets
683  $_mailbox = substr($_mailbox, strpos($_mailbox, '(' . $comment) + strlen($comment) + 2);
684  } else {
685  break;
686  }
687  }
688 
689  foreach ($comments as $comment) {
690  $mailbox = str_replace("($comment)", '', $mailbox);
691  }
692 
693  $mailbox = trim($mailbox);
694 
695  // Check for name + route-addr
696  if (substr($mailbox, -1) === '>' && $mailbox[0] !== '<') {
697  $parts = explode('<', $mailbox);
698  $name = $this->_splitCheck($parts, '<');
699 
700  $phrase = trim($name);
701  $route_addr = trim(substr($mailbox, strlen($name . '<'), -1));
702 
703  if ($this->_validatePhrase($phrase) === false ||
704  ($route_addr = $this->_validateRouteAddr($route_addr)) === false) {
705  return false;
706  }
707 
708  // Only got addr-spec
709  } else {
710  // First snip angle brackets if present.
711  if ($mailbox[0] === '<' && substr($mailbox, -1) === '>') {
712  $addr_spec = substr($mailbox, 1, -1);
713  } else {
714  $addr_spec = $mailbox;
715  }
716 
717  if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) {
718  return false;
719  }
720  }
721 
722  // Construct the object that will be returned.
723  $mbox = new stdClass();
724 
725  // Add the phrase (even if empty) and comments
726  $mbox->personal = $phrase;
727  $mbox->comment = $comments ?? [];
728 
729  if (isset($route_addr)) {
730  $mbox->mailbox = $route_addr['local_part'];
731  $mbox->host = $route_addr['domain'];
732  if ($route_addr['adl'] !== '') {
733  $mbox->adl = $route_addr['adl'];
734  }
735  } else {
736  $mbox->mailbox = $addr_spec['local_part'];
737  $mbox->host = $addr_spec['domain'];
738  }
739 
740  $mailbox = $mbox;
741  return true;
742  }
743 
754  protected function _validateRouteAddr(string $route_addr)
755  {
756  // Check for colon.
757  if (strpos($route_addr, ':') !== false) {
758  $parts = explode(':', $route_addr);
759  $route = $this->_splitCheck($parts, ':');
760  } else {
761  $route = $route_addr;
762  }
763 
764  // If $route is same as $route_addr then the colon was in
765  // quotes or brackets or, of course, non existent.
766  if ($route === $route_addr) {
767  unset($route);
768  $addr_spec = $route_addr;
769  if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) {
770  return false;
771  }
772  } else {
773  // Validate route part.
774  if (($route = $this->_validateRoute($route)) === false) {
775  return false;
776  }
777 
778  $addr_spec = substr($route_addr, strlen($route . ':'));
779 
780  // Validate addr-spec part.
781  if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) {
782  return false;
783  }
784  }
785 
786  if (isset($route)) {
787  $return['adl'] = $route;
788  } else {
789  $return['adl'] = '';
790  }
791 
792  $return = array_merge($return, $addr_spec);
793  return $return;
794  }
795 
803  protected function _validateRoute(string $route)
804  {
805  // Split on comma.
806  $domains = explode(',', trim($route));
807 
808  foreach ($domains as $domain) {
809  $domain = str_replace('@', '', trim($domain));
810  if (!$this->_validateDomain($domain)) {
811  return false;
812  }
813  }
814 
815  return $route;
816  }
817 
827  protected function _validateDomain(string $domain)
828  {
829  // Note the different use of $subdomains and $sub_domains
830  $subdomains = explode('.', $domain);
831 
832  $sub_domains = [];
833  while (count($subdomains) > 0) {
834  $sub_domains[] = $this->_splitCheck($subdomains, '.');
835  for ($i = 0; $i < $this->index + 1; $i++) {
836  array_shift($subdomains);
837  }
838  }
839 
840  foreach ($sub_domains as $sub_domain) {
841  if (!$this->_validateSubdomain(trim($sub_domain))) {
842  return false;
843  }
844  }
845 
846  // Managed to get here, so return input.
847  return $domain;
848  }
849 
857  protected function _validateSubdomain(string $subdomain): bool
858  {
859  if (preg_match('|^\[(.*)]$|', $subdomain, $arr)) {
860  if (!$this->_validateDliteral($arr[1])) {
861  return false;
862  }
863  } elseif (!$this->_validateAtom($subdomain)) {
864  return false;
865  }
866 
867  // Got here, so return successful.
868  return true;
869  }
870 
878  protected function _validateDliteral(string $dliteral): bool
879  {
880  return !preg_match('/(.)[][\x0D\\\\]/', $dliteral, $matches) &&
881  ((!isset($matches[1])) || $matches[1] != '\\');
882  }
883 
892  protected function _validateAddrSpec(string $addr_spec)
893  {
894  $addr_spec = trim($addr_spec);
895 
896  // mjansen patch 16 Sep 2016 start
897  $validateState = $this->validate;
898  // mjansen patch 16 Sep 2016 end
899  // Split on @ sign if there is one.
900  if (strpos($addr_spec, '@') !== false) {
901  $parts = explode('@', $addr_spec);
902  $local_part = $this->_splitCheck($parts, '@');
903  $domain = substr($addr_spec, strlen($local_part . '@'));
904  // mjansen patch 16 Sep 2016 start
905  if (substr_count($addr_spec, '@') !== 1 && $local_part === '') {
906  $this->validate = false;
907  $local_part = $addr_spec;
908  $domain = $this->default_domain;
909  }
910  // mjansen patch 16 Sep 2016 end
911  // No @ sign so assume the default domain.
912  } else {
913  $local_part = $addr_spec;
914  $domain = $this->default_domain;
915  }
916 
917  if (($local_part = $this->_validateLocalPart($local_part)) === false) {
918  return false;
919  }
920  // mjansen patch 16 Sep 2016 start
921  if ($validateState !== $this->validate) {
922  $this->validate = $validateState;
923  }
924  // mjansen patch 16 Sep 2016 end
925  if (($domain = $this->_validateDomain($domain)) === false) {
926  return false;
927  }
928 
929  // Got here so return successful.
930  return ['local_part' => $local_part, 'domain' => $domain];
931  }
932 
941  protected function _validateLocalPart(string $local_part)
942  {
943  $parts = explode('.', $local_part);
944  $words = [];
945 
946  // Split the local_part into words.
947  while (count($parts) > 0) {
948  $words[] = $this->_splitCheck($parts, '.');
949  for ($i = 0; $i < $this->index + 1; $i++) {
950  array_shift($parts);
951  }
952  }
953 
954  // Validate each word.
955  foreach ($words as $word) {
956  // iszmais patch 19 May 2020 start
957  // word cannot be empty (#17317)
958  //if ($word === '') {
959  // return false;
960  //}
961  // iszmais patch 19 May 2020 end
962  // If this word contains an unquoted space, it is invalid. (6.2.4)
963  if (strpos($word, ' ') && $word[0] !== '"') {
964  // mjansen patch 24 Feb 2016 start
965  // Mantis issue #18018
966  // # http://haacked.com/archive/2007/08/21/i-knew-how-to-validate-an-email-address-until-i.aspx/
967  //return false;
968  // mjansen patch 24 Feb 2016 end
969  }
970 
971  if ($this->_validatePhrase(trim($word)) === false) {
972  return false;
973  }
974  }
975 
976  // Managed to get here, so return the input.
977  return $local_part;
978  }
979 
990  public function approximateCount(string $data): int
991  {
992  return count(preg_split('/(?<!\\\\),/', $data));
993  }
994 
1008  public function isValidInetAddress(string $data, bool $strict = false)
1009  {
1010  $regex =
1011  $strict ?
1012  '/^([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})$/i' :
1013  '/^([*+!.&#$|\'\\%\/0-9a-z^_`{}=?~:-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})$/i';
1014  if (preg_match($regex, trim($data), $matches)) {
1015  return [$matches[1], $matches[2]];
1016  }
1017 
1018  return false;
1019  }
1020 }
_validateQuotedString(string $qstring)
Function to validate quoted string, which is: quoted-string = <"> *(qtext/quoted-pair) <"> ...
Definition: RFC822.php:646
_validateAddrSpec(string $addr_spec)
Function to validate an addr-spec.
Definition: RFC822.php:892
int $num_groups
The number of groups that have been found in the address list.
Definition: RFC822.php:146
_isGroup(string $address)
Checks for a group at the start of the string.
Definition: RFC822.php:349
bool $nestGroups
Should we return a nested array showing groups, or flatten everything?
Definition: RFC822.php:109
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:64
_hasUnclosedBrackets(string $string, string $chars)
Checks if a string has an unclosed brackets or not.
Definition: RFC822.php:441
_validateLocalPart(string $local_part)
Function to validate the local part of an address: local-part = word *("." word)
Definition: RFC822.php:941
_validateAddress(array $address)
Function to begin checking the address.
Definition: RFC822.php:486
$valid
string $default_domain
The default domain to use for unqualified addresses.
Definition: RFC822.php:103
__construct(string $address=null, string $default_domain=null, bool $nest_groups=null, bool $validate=null, int $limit=null)
Sets up the object.
Definition: RFC822.php:171
_validateDomain(string $domain)
Function to validate a domain, though this is not quite what you expect of a strict internet domain...
Definition: RFC822.php:827
_hasUnclosedQuotes(string $string)
Checks if a string has unclosed quotes or not.
Definition: RFC822.php:404
_validateRoute(string $route)
Function to validate a route, which is: route = 1#("@" domain) ":".
Definition: RFC822.php:803
bool $validate
Whether or not to validate atoms for non-ascii characters.
Definition: RFC822.php:115
_validateAtom(string $atom)
Function to validate an atom which from rfc822 is: atom = 1*<any CHAR except specials, SPACE and CTLs>
Definition: RFC822.php:611
_validateRouteAddr(string $route_addr)
This function validates a route-addr which is: route-addr = "<" [route] addr-spec ">"...
Definition: RFC822.php:754
array $structure
The final array of parsed address information that we build up.
Definition: RFC822.php:127
isValidInetAddress(string $data, bool $strict=false)
This is a email validating function separate to the rest of the class.
Definition: RFC822.php:1008
_validateSubdomain(string $subdomain)
Function to validate a subdomain: subdomain = domain-ref / domain-literal.
Definition: RFC822.php:857
if($format !==null) $name
Definition: metadata.php:247
_hasUnclosedBracketsSub(string $string, int &$num, string $char)
Sub function that is used only by hasUnclosedBrackets().
Definition: RFC822.php:465
bool $mailRFC822
A variable so that we can tell whether or not we&#39;re inside a Mail_RFC822 object.
Definition: RFC822.php:153
int $limit
A limit after which processing stops.
Definition: RFC822.php:159
string $error
The current error message, if any.
Definition: RFC822.php:133
$comments
approximateCount(string $data)
Returns an approximate count of how many addresses are in the given string.
Definition: RFC822.php:990
$comment
Definition: buildRTE.php:72
parseAddressList(string $address=null, string $default_domain=null, bool $nest_groups=null, bool $validate=null, int $limit=null)
Starts the whole process.
Definition: RFC822.php:206
validateMailbox(string &$mailbox)
Function to validate a mailbox, which is: mailbox = addr-spec ; simple address / phrase route-addr ; ...
Definition: RFC822.php:663
_splitCheck(array $parts, string $char)
A common function that will check an exploded string.
Definition: RFC822.php:373
string $address
The address being parsed by the RFC822 object.
Definition: RFC822.php:97
_validateDliteral(string $dliteral)
Function to validate a domain literal: domain-literal = "[" *(dtext / quoted-pair) "]"...
Definition: RFC822.php:878
_splitAddresses(string $address)
Splits an address into separate addresses.
Definition: RFC822.php:281
array $addresses
The array of raw addresses built up as we parse.
Definition: RFC822.php:121
_validatePhrase(string $phrase)
Function to validate a phrase.
Definition: RFC822.php:568
$i
Definition: metadata.php:41
int $index
An internal counter/pointer.
Definition: RFC822.php:139