cvs: php4 /pear/Mail RFC822.php
| From: | Richard Heyes | Date: | Mon, 29 Oct 2001 14:14:44 +0000 |
| Subject: | cvs: php4 /pear/Mail RFC822.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-1183@lists.php.net to get a copy of this message | ||
heyesr Mon Oct 29 09:14:44 2001 EDT
Modified files:
/php4/pear/Mail RFC822.php
Log:
Prefixed private methods with _
Index: php4/pear/Mail/RFC822.php diff -u php4/pear/Mail/RFC822.php:1.13 php4/pear/Mail/RFC822.php:1.14 --- php4/pear/Mail/RFC822.php:1.13 Mon Oct 29 08:48:13 2001 +++ php4/pear/Mail/RFC822.php Mon Oct 29 09:14:44 2001 @@ -38,7 +38,7 @@ * * @author Richard Heyes <richard@phpguru.org> * @author Chuck Hagenbuch <chuck@horde.org> -* @version $Revision: 1.13 $ +* @version $Revision: 1.14 $ * @package Mail */ @@ -142,6 +142,7 @@ */ function parseAddressList($address = null, $default_domain = null, $nest_groups = null, $validate = null) { + if (!isset($this->mailRFC822)) { $obj = new Mail_RFC822($address, $default_domain, $nest_groups, $validate); return $obj->parseAddressList(); @@ -157,12 +158,12 @@ $this->error = null; $this->index = null; - if (!$this->splitAddresses($this->address) || isset($this->error)) { + if (!$this->_splitAddresses($this->address) || isset($this->error)) { return $this->raiseError($this->error); } for ($i = 0; $i < count($this->addresses); $i++){ - if (($return = $this->validateAddress($this->addresses[$i])) === false + if (($return = $this->_validateAddress($this->addresses[$i])) === false || isset($this->error)) { return $this->raiseError($this->error); } @@ -184,10 +185,10 @@ * @param string $address The addresses to split. * @return boolean Success or failure. */ - function splitAddresses($address = '') + function _splitAddresses($address = '') { - if ($this->isGroup($address) && !isset($this->error)) { + if ($this->_isGroup($address) && !isset($this->error)) { $split_char = ';'; $is_group = true; } elseif (!isset($this->error)) { @@ -199,7 +200,7 @@ // Split the string based on the above ten or so lines. $parts = explode($split_char, $address); - $string = $this->splitCheck($parts, $split_char); + $string = $this->_splitCheck($parts, $split_char); // If a group... if ($is_group) { @@ -213,7 +214,7 @@ } // Now check it's outside of brackets/quotes: - if (!$this->splitCheck(explode(':', $string), ':')) + if (!$this->_splitCheck(explode(':', $string), ':')) return false; // We must have a group at this point, so increase the counter: @@ -236,11 +237,11 @@ // chars, then there is another address. if ($is_group && substr($address, 0, 1) == ','){ $address = trim(substr($address, 1)); - $this->splitAddresses($address); + $this->_splitAddresses($address); return true; } elseif (strlen($address) > 0) { - $this->splitAddresses($address); + $this->_splitAddresses($address); return true; } else { return true; @@ -257,17 +258,17 @@ * @param string $address The address to check. * @return boolean Whether or not there is a group at the start of the string. */ - function isGroup($address) + function _isGroup($address) { // First comma not in quotes, angles or escaped: $parts = explode(',', $address); - $string = $this->splitCheck($parts, ','); + $string = $this->_splitCheck($parts, ','); // Now we have the first address, we can reliably check for a // group by searching for a colon that's not escaped or in // quotes or angle brackets. if (count($parts = explode(':', $string)) > 1) { - $string2 = $this->splitCheck($parts, ':'); + $string2 = $this->_splitCheck($parts, ':'); return ($string2 !== $string); } else { return false; @@ -282,15 +283,15 @@ * @param string $char The char that was exploded on. * @return mixed False if the string contains unclosed quotes/brackets, or the string on success. */ - function splitCheck($parts, $char) + function _splitCheck($parts, $char) { $string = $parts[0]; for ($i = 0; $i < count($parts); $i++) { - if ($this->hasUnclosedQuotes($string) - || $this->hasUnclosedBrackets($string, '<>') - || $this->hasUnclosedBrackets($string, '[]') - || $this->hasUnclosedBrackets($string, '()') + if ($this->_hasUnclosedQuotes($string) + || $this->_hasUnclosedBrackets($string, '<>') + || $this->_hasUnclosedBrackets($string, '[]') + || $this->_hasUnclosedBrackets($string, '()') || substr($string, -1) == '\\') { if (isset($parts[$i + 1])) { $string = $string . $char . $parts[$i + 1]; @@ -314,7 +315,7 @@ * @param string $string The string to check. * @return boolean True if there are unclosed quotes inside the string, false otherwise. */ - function hasUnclosedQuotes($string) + function _hasUnclosedQuotes($string) { $string = explode('"', $string); $string_cnt = count($string); @@ -335,13 +336,13 @@ * @param string $chars The characters to check for. * @return boolean True if there are unclosed brackets inside the string, false otherwise. */ - function hasUnclosedBrackets($string, $chars) + function _hasUnclosedBrackets($string, $chars) { $num_angle_start = substr_count($string, $chars[0]); $num_angle_end = substr_count($string, $chars[1]); - $this->hasUnclosedBracketsSub($string, $num_angle_start, $chars[0]); - $this->hasUnclosedBracketsSub($string, $num_angle_end, $chars[1]); + $this->_hasUnclosedBracketsSub($string, $num_angle_start, $chars[0]); + $this->_hasUnclosedBracketsSub($string, $num_angle_end, $chars[1]); if ($num_angle_start < $num_angle_end) { $this->error = 'Invalid address spec. Unmatched quote or bracket (' . $chars . ')'; @@ -360,11 +361,11 @@ * @param string $char The character to count. * @return integer The number of occurences of $char in $string, adjusted for backslashes. */ - function hasUnclosedBracketsSub($string, &$num, $char) + function _hasUnclosedBracketsSub($string, &$num, $char) { $parts = explode($char, $string); for ($i = 0; $i < count($parts); $i++){ - if (substr($parts[$i], -1) == '\\' || $this->hasUnclosedQuotes($parts[$i])) + if (substr($parts[$i], -1) == '\\' || $this->_hasUnclosedQuotes($parts[$i])) $num--; if (isset($parts[$i + 1])) $parts[$i + 1] = $parts[$i] . $char . $parts[$i + 1]; @@ -380,7 +381,7 @@ * @param string $address The address to validate. * @return mixed False on failure, or a structured array of address information on success. */ - function validateAddress($address) + function _validateAddress($address) { $is_group = false; @@ -389,11 +390,11 @@ // Get the group part of the name $parts = explode(':', $address['address']); - $groupname = $this->splitCheck($parts, ':'); + $groupname = $this->_splitCheck($parts, ':'); $structure = array(); // And validate the group part of the name. - if (!$this->validatePhrase($groupname)){ + if (!$this->_validatePhrase($groupname)){ $this->error = 'Group name did not validate.'; return false; } else { @@ -413,7 +414,7 @@ if ($is_group) { while (strlen($address['address']) > 0) { $parts = explode(',', $address['address']); - $addresses[] = $this->splitCheck($parts, ','); + $addresses[] = $this->_splitCheck($parts, ','); $address['address'] = trim(substr($address['address'], strlen(end($addresses) . ','))); } } else { @@ -437,7 +438,7 @@ // geezer@domain.com // geezer // ... or any other format valid by RFC 822. - array_walk($addresses, array($this, 'validateMailbox')); + array_walk($addresses, array($this, '_validateMailbox')); // Nested format if ($this->nestGroups) { @@ -466,14 +467,14 @@ * @param string $phrase The phrase to check. * @return boolean Success or failure. */ - function validatePhrase($phrase) + function _validatePhrase($phrase) { // Splits on one or more Tab or space. $parts = preg_split('/[ \\x09]+/', $phrase, -1, PREG_SPLIT_NO_EMPTY); $phrase_parts = array(); while (count($parts) > 0){ - $phrase_parts[] = $this->splitCheck($parts, ' '); + $phrase_parts[] = $this->_splitCheck($parts, ' '); for ($i = 0; $i < $this->index + 1; $i++) array_shift($parts); } @@ -481,13 +482,13 @@ for ($i = 0; $i < count($phrase_parts); $i++) { // If quoted string: if (substr($phrase_parts[$i], 0, 1) == '"') { - if (!$this->validateQuotedString($phrase_parts[$i])) + if (!$this->_validateQuotedString($phrase_parts[$i])) return false; continue; } // Otherwise it's an atom: - if (!$this->validateAtom($phrase_parts[$i])) return false; + if (!$this->_validateAtom($phrase_parts[$i])) return false; } return true; @@ -506,7 +507,7 @@ * @param string $atom The string to check. * @return boolean Success or failure. */ - function validateAtom($atom) + function _validateAtom($atom) { if (!$this->validate) { // Validation has been turned off; assume the atom is okay. @@ -539,7 +540,7 @@ * @param string $qstring The string to check * @return boolean Success or failure. */ - function validateQuotedString($qstring) + function _validateQuotedString($qstring) { // Leading and trailing " $qstring = substr($qstring, 1, -1); @@ -557,7 +558,7 @@ * @param string &$mailbox The string to check. * @return boolean Success or failure. */ - function validateMailbox(&$mailbox) + function _validateMailbox(&$mailbox) { // A couple of defaults. $phrase = ''; @@ -567,12 +568,12 @@ $_mailbox = $mailbox; while(strlen(trim($_mailbox)) > 0){ $parts = explode('(', $_mailbox); - $before_comment = $this->splitCheck($parts, '('); + $before_comment = $this->_splitCheck($parts, '('); if($before_comment != $_mailbox){ // First char should be a ( $comment = substr(str_replace($before_comment, '', $_mailbox), 1); $parts = explode(')', $comment); - $comment = $this->splitCheck($parts, ')'); + $comment = $this->_splitCheck($parts, ')'); $comments[] = $comment; // +1 is for the trailing ) @@ -590,12 +591,12 @@ // Check for name + route-addr if (substr($mailbox, -1) == '>' && substr($mailbox, 0, 1) != '<') { $parts = explode('<', $mailbox); - $name = $this->splitCheck($parts, '<'); + $name = $this->_splitCheck($parts, '<'); $phrase = trim($name); $route_addr = trim(substr($mailbox, strlen($name.'<'), -1)); - if ($this->validatePhrase($phrase) === false || ($route_addr = $this->validateRouteAddr($route_addr)) === false) + if ($this->_validatePhrase($phrase) === false || ($route_addr = $this->_validateRouteAddr($route_addr)) === false) return false; // Only got addr-spec @@ -606,7 +607,7 @@ else $addr_spec = $mailbox; - if (($addr_spec = $this->validateAddrSpec($addr_spec)) === false) + if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) return false; } @@ -650,12 +651,12 @@ * @param string $route_addr The string to check. * @return mixed False on failure, or an array containing validated address/route information on success. */ - function validateRouteAddr($route_addr) + function _validateRouteAddr($route_addr) { // Check for colon. if (strpos($route_addr, ':') !== false) { $parts = explode(':', $route_addr); - $route = $this->splitCheck($parts, ':'); + $route = $this->_splitCheck($parts, ':'); } else { $route = $route_addr; } @@ -665,19 +666,19 @@ if ($route === $route_addr){ unset($route); $addr_spec = $route_addr; - if (($addr_spec = $this->validateAddrSpec($addr_spec)) === false) { + if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) { return false; } } else { // Validate route part. - if (($route = $this->validateRoute($route)) === false) { + if (($route = $this->_validateRoute($route)) === false) { return false; } $addr_spec = substr($route_addr, strlen($route . ':')); // Validate addr-spec part. - if (($addr_spec = $this->validateAddrSpec($addr_spec)) === false) { + if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) { return false; } } @@ -700,14 +701,14 @@ * @param string $route The string to check. * @return mixed False on failure, or the validated $route on success. */ - function validateRoute($route) + function _validateRoute($route) { // Split on comma. $domains = explode(',', trim($route)); for ($i = 0; $i < count($domains); $i++) { $domains[$i] = str_replace('@', '', trim($domains[$i])); - if (!$this->validateDomain($domains[$i])) return false; + if (!$this->_validateDomain($domains[$i])) return false; } return $route; @@ -723,19 +724,19 @@ * @param string $domain The string to check. * @return mixed False on failure, or the validated domain on success. */ - function validateDomain($domain) + function _validateDomain($domain) { // Note the different use of $subdomains and $sub_domains $subdomains = explode('.', $domain); while (count($subdomains) > 0) { - $sub_domains[] = $this->splitCheck($subdomains, '.'); + $sub_domains[] = $this->_splitCheck($subdomains, '.'); for ($i = 0; $i < $this->index + 1; $i++) array_shift($subdomains); } for ($i = 0; $i < count($sub_domains); $i++) { - if (!$this->validateSubdomain(trim($sub_domains[$i]))) + if (!$this->_validateSubdomain(trim($sub_domains[$i]))) return false; } @@ -751,12 +752,12 @@ * @param string $subdomain The string to check. * @return boolean Success or failure. */ - function validateSubdomain($subdomain) + function _validateSubdomain($subdomain) { if (preg_match('|^\[(.*)]$|', $subdomain, $arr)){ - if (!$this->validateDliteral($arr[1])) return false; + if (!$this->_validateDliteral($arr[1])) return false; } else { - if (!$this->validateAtom($subdomain)) return false; + if (!$this->_validateAtom($subdomain)) return false; } // Got here, so return successful. @@ -771,7 +772,7 @@ * @param string $dliteral The string to check. * @return boolean Success or failure. */ - function validateDliteral($dliteral) + function _validateDliteral($dliteral) { return !preg_match('/(.)[][\x0D\\\\]/', $dliteral, $matches) && $matches[1] != '\\'; } @@ -785,14 +786,14 @@ * @param string $addr_spec The string to check. * @return mixed False on failure, or the validated addr-spec on success. */ - function validateAddrSpec($addr_spec) + function _validateAddrSpec($addr_spec) { $addr_spec = trim($addr_spec); // Split on @ sign if there is one. if (strpos($addr_spec, '@') !== false) { $parts = explode('@', $addr_spec); - $local_part = $this->splitCheck($parts, '@'); + $local_part = $this->_splitCheck($parts, '@'); $domain = substr($addr_spec, strlen($local_part . '@')); // No @ sign so assume the default domain. @@ -801,8 +802,8 @@ $domain = $this->default_domain; } - if (($local_part = $this->validateLocalPart($local_part)) === false) return false; - if (($domain = $this->validateDomain($domain)) === false) return false; + if (($local_part = $this->_validateLocalPart($local_part)) === false) return false; + if (($domain = $this->_validateDomain($domain)) === false) return false; // Got here so return successful. return array('local_part' => $local_part, 'domain' => $domain); @@ -816,13 +817,13 @@ * @param string $local_part * @return mixed False on failure, or the validated local part on success. */ - function validateLocalPart($local_part) + function _validateLocalPart($local_part) { $parts = explode('.', $local_part); // Split the local_part into words. while (count($parts) > 0){ - $words[] = $this->splitCheck($parts, '.'); + $words[] = $this->_splitCheck($parts, '.'); for ($i = 0; $i < $this->index + 1; $i++) { array_shift($parts); } @@ -830,7 +831,7 @@ // Validate each word. for ($i = 0; $i < count($words); $i++) { - if ($this->validatePhrase(trim($words[$i])) === false) return false; + if ($this->_validatePhrase(trim($words[$i])) === false) return false; } // Managed to get here, so return the input.
Index: php4/pear/Mail/RFC822.php diff -u php4/pear/Mail/RFC822.php:1.13 php4/pear/Mail/RFC822.php:1.14 --- php4/pear/Mail/RFC822.php:1.13 Mon Oct 29 08:48:13 2001 +++ php4/pear/Mail/RFC822.php Mon Oct 29 09:14:44 2001 @@ -38,7 +38,7 @@ * * @author Richard Heyes <richard@phpguru.org> * @author Chuck Hagenbuch <chuck@horde.org> -* @version $Revision: 1.13 $ +* @version $Revision: 1.14 $ * @package Mail */ @@ -142,6 +142,7 @@ */ function parseAddressList($address = null, $default_domain = null, $nest_groups = null, $validate = null) { + if (!isset($this->mailRFC822)) { $obj = new Mail_RFC822($address, $default_domain, $nest_groups, $validate); return $obj->parseAddressList(); @@ -157,12 +158,12 @@ $this->error = null; $this->index = null; - if (!$this->splitAddresses($this->address) || isset($this->error)) { + if (!$this->_splitAddresses($this->address) || isset($this->error)) { return $this->raiseError($this->error); } for ($i = 0; $i < count($this->addresses); $i++){ - if (($return = $this->validateAddress($this->addresses[$i])) === false + if (($return = $this->_validateAddress($this->addresses[$i])) === false || isset($this->error)) { return $this->raiseError($this->error); } @@ -184,10 +185,10 @@ * @param string $address The addresses to split. * @return boolean Success or failure. */ - function splitAddresses($address = '') + function _splitAddresses($address = '') { - if ($this->isGroup($address) && !isset($this->error)) { + if ($this->_isGroup($address) && !isset($this->error)) { $split_char = ';'; $is_group = true; } elseif (!isset($this->error)) { @@ -199,7 +200,7 @@ // Split the string based on the above ten or so lines. $parts = explode($split_char, $address); - $string = $this->splitCheck($parts, $split_char); + $string = $this->_splitCheck($parts, $split_char); // If a group... if ($is_group) { @@ -213,7 +214,7 @@ } // Now check it's outside of brackets/quotes: - if (!$this->splitCheck(explode(':', $string), ':')) + if (!$this->_splitCheck(explode(':', $string), ':')) return false; // We must have a group at this point, so increase the counter: @@ -236,11 +237,11 @@ // chars, then there is another address. if ($is_group && substr($address, 0, 1) == ','){ $address = trim(substr($address, 1)); - $this->splitAddresses($address); + $this->_splitAddresses($address); return true; } elseif (strlen($address) > 0) { - $this->splitAddresses($address); + $this->_splitAddresses($address); return true; } else { return true; @@ -257,17 +258,17 @@ * @param string $address The address to check. * @return boolean Whether or not there is a group at the start of the string. */ - function isGroup($address) + function _isGroup($address) { // First comma not in quotes, angles or escaped: $parts = explode(',', $address); - $string = $this->splitCheck($parts, ','); + $string = $this->_splitCheck($parts, ','); // Now we have the first address, we can reliably check for a // group by searching for a colon that's not escaped or in // quotes or angle brackets. if (count($parts = explode(':', $string)) > 1) { - $string2 = $this->splitCheck($parts, ':'); + $string2 = $this->_splitCheck($parts, ':'); return ($string2 !== $string); } else { return false; @@ -282,15 +283,15 @@ * @param string $char The char that was exploded on. * @return mixed False if the string contains unclosed quotes/brackets, or the string on success. */ - function splitCheck($parts, $char) + function _splitCheck($parts, $char) { $string = $parts[0]; for ($i = 0; $i < count($parts); $i++) { - if ($this->hasUnclosedQuotes($string) - || $this->hasUnclosedBrackets($string, '<>') - || $this->hasUnclosedBrackets($string, '[]') - || $this->hasUnclosedBrackets($string, '()') + if ($this->_hasUnclosedQuotes($string) + || $this->_hasUnclosedBrackets($string, '<>') + || $this->_hasUnclosedBrackets($string, '[]') + || $this->_hasUnclosedBrackets($string, '()') || substr($string, -1) == '\\') { if (isset($parts[$i + 1])) { $string = $string . $char . $parts[$i + 1]; @@ -314,7 +315,7 @@ * @param string $string The string to check. * @return boolean True if there are unclosed quotes inside the string, false otherwise. */ - function hasUnclosedQuotes($string) + function _hasUnclosedQuotes($string) { $string = explode('"', $string); $string_cnt = count($string); @@ -335,13 +336,13 @@ * @param string $chars The characters to check for. * @return boolean True if there are unclosed brackets inside the string, false otherwise. */ - function hasUnclosedBrackets($string, $chars) + function _hasUnclosedBrackets($string, $chars) { $num_angle_start = substr_count($string, $chars[0]); $num_angle_end = substr_count($string, $chars[1]); - $this->hasUnclosedBracketsSub($string, $num_angle_start, $chars[0]); - $this->hasUnclosedBracketsSub($string, $num_angle_end, $chars[1]); + $this->_hasUnclosedBracketsSub($string, $num_angle_start, $chars[0]); + $this->_hasUnclosedBracketsSub($string, $num_angle_end, $chars[1]); if ($num_angle_start < $num_angle_end) { $this->error = 'Invalid address spec. Unmatched quote or bracket (' . $chars . ')'; @@ -360,11 +361,11 @@ * @param string $char The character to count. * @return integer The number of occurences of $char in $string, adjusted for backslashes. */ - function hasUnclosedBracketsSub($string, &$num, $char) + function _hasUnclosedBracketsSub($string, &$num, $char) { $parts = explode($char, $string); for ($i = 0; $i < count($parts); $i++){ - if (substr($parts[$i], -1) == '\\' || $this->hasUnclosedQuotes($parts[$i])) + if (substr($parts[$i], -1) == '\\' || $this->_hasUnclosedQuotes($parts[$i])) $num--; if (isset($parts[$i + 1])) $parts[$i + 1] = $parts[$i] . $char . $parts[$i + 1]; @@ -380,7 +381,7 @@ * @param string $address The address to validate. * @return mixed False on failure, or a structured array of address information on success. */ - function validateAddress($address) + function _validateAddress($address) { $is_group = false; @@ -389,11 +390,11 @@ // Get the group part of the name $parts = explode(':', $address['address']); - $groupname = $this->splitCheck($parts, ':'); + $groupname = $this->_splitCheck($parts, ':'); $structure = array(); // And validate the group part of the name. - if (!$this->validatePhrase($groupname)){ + if (!$this->_validatePhrase($groupname)){ $this->error = 'Group name did not validate.'; return false; } else { @@ -413,7 +414,7 @@ if ($is_group) { while (strlen($address['address']) > 0) { $parts = explode(',', $address['address']); - $addresses[] = $this->splitCheck($parts, ','); + $addresses[] = $this->_splitCheck($parts, ','); $address['address'] = trim(substr($address['address'], strlen(end($addresses) . ','))); } } else { @@ -437,7 +438,7 @@ // geezer@domain.com // geezer // ... or any other format valid by RFC 822. - array_walk($addresses, array($this, 'validateMailbox')); + array_walk($addresses, array($this, '_validateMailbox')); // Nested format if ($this->nestGroups) { @@ -466,14 +467,14 @@ * @param string $phrase The phrase to check. * @return boolean Success or failure. */ - function validatePhrase($phrase) + function _validatePhrase($phrase) { // Splits on one or more Tab or space. $parts = preg_split('/[ \\x09]+/', $phrase, -1, PREG_SPLIT_NO_EMPTY); $phrase_parts = array(); while (count($parts) > 0){ - $phrase_parts[] = $this->splitCheck($parts, ' '); + $phrase_parts[] = $this->_splitCheck($parts, ' '); for ($i = 0; $i < $this->index + 1; $i++) array_shift($parts); } @@ -481,13 +482,13 @@ for ($i = 0; $i < count($phrase_parts); $i++) { // If quoted string: if (substr($phrase_parts[$i], 0, 1) == '"') { - if (!$this->validateQuotedString($phrase_parts[$i])) + if (!$this->_validateQuotedString($phrase_parts[$i])) return false; continue; } // Otherwise it's an atom: - if (!$this->validateAtom($phrase_parts[$i])) return false; + if (!$this->_validateAtom($phrase_parts[$i])) return false; } return true; @@ -506,7 +507,7 @@ * @param string $atom The string to check. * @return boolean Success or failure. */ - function validateAtom($atom) + function _validateAtom($atom) { if (!$this->validate) { // Validation has been turned off; assume the atom is okay. @@ -539,7 +540,7 @@ * @param string $qstring The string to check * @return boolean Success or failure. */ - function validateQuotedString($qstring) + function _validateQuotedString($qstring) { // Leading and trailing " $qstring = substr($qstring, 1, -1); @@ -557,7 +558,7 @@ * @param string &$mailbox The string to check. * @return boolean Success or failure. */ - function validateMailbox(&$mailbox) + function _validateMailbox(&$mailbox) { // A couple of defaults. $phrase = ''; @@ -567,12 +568,12 @@ $_mailbox = $mailbox; while(strlen(trim($_mailbox)) > 0){ $parts = explode('(', $_mailbox); - $before_comment = $this->splitCheck($parts, '('); + $before_comment = $this->_splitCheck($parts, '('); if($before_comment != $_mailbox){ // First char should be a ( $comment = substr(str_replace($before_comment, '', $_mailbox), 1); $parts = explode(')', $comment); - $comment = $this->splitCheck($parts, ')'); + $comment = $this->_splitCheck($parts, ')'); $comments[] = $comment; // +1 is for the trailing ) @@ -590,12 +591,12 @@ // Check for name + route-addr if (substr($mailbox, -1) == '>' && substr($mailbox, 0, 1) != '<') { $parts = explode('<', $mailbox); - $name = $this->splitCheck($parts, '<'); + $name = $this->_splitCheck($parts, '<'); $phrase = trim($name); $route_addr = trim(substr($mailbox, strlen($name.'<'), -1)); - if ($this->validatePhrase($phrase) === false || ($route_addr = $this->validateRouteAddr($route_addr)) === false) + if ($this->_validatePhrase($phrase) === false || ($route_addr = $this->_validateRouteAddr($route_addr)) === false) return false; // Only got addr-spec @@ -606,7 +607,7 @@ else $addr_spec = $mailbox; - if (($addr_spec = $this->validateAddrSpec($addr_spec)) === false) + if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) return false; } @@ -650,12 +651,12 @@ * @param string $route_addr The string to check. * @return mixed False on failure, or an array containing validated address/route information on success. */ - function validateRouteAddr($route_addr) + function _validateRouteAddr($route_addr) { // Check for colon. if (strpos($route_addr, ':') !== false) { $parts = explode(':', $route_addr); - $route = $this->splitCheck($parts, ':'); + $route = $this->_splitCheck($parts, ':'); } else { $route = $route_addr; } @@ -665,19 +666,19 @@ if ($route === $route_addr){ unset($route); $addr_spec = $route_addr; - if (($addr_spec = $this->validateAddrSpec($addr_spec)) === false) { + if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) { return false; } } else { // Validate route part. - if (($route = $this->validateRoute($route)) === false) { + if (($route = $this->_validateRoute($route)) === false) { return false; } $addr_spec = substr($route_addr, strlen($route . ':')); // Validate addr-spec part. - if (($addr_spec = $this->validateAddrSpec($addr_spec)) === false) { + if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) { return false; } } @@ -700,14 +701,14 @@ * @param string $route The string to check. * @return mixed False on failure, or the validated $route on success. */ - function validateRoute($route) + function _validateRoute($route) { // Split on comma. $domains = explode(',', trim($route)); for ($i = 0; $i < count($domains); $i++) { $domains[$i] = str_replace('@', '', trim($domains[$i])); - if (!$this->validateDomain($domains[$i])) return false; + if (!$this->_validateDomain($domains[$i])) return false; } return $route; @@ -723,19 +724,19 @@ * @param string $domain The string to check. * @return mixed False on failure, or the validated domain on success. */ - function validateDomain($domain) + function _validateDomain($domain) { // Note the different use of $subdomains and $sub_domains $subdomains = explode('.', $domain); while (count($subdomains) > 0) { - $sub_domains[] = $this->splitCheck($subdomains, '.'); + $sub_domains[] = $this->_splitCheck($subdomains, '.'); for ($i = 0; $i < $this->index + 1; $i++) array_shift($subdomains); } for ($i = 0; $i < count($sub_domains); $i++) { - if (!$this->validateSubdomain(trim($sub_domains[$i]))) + if (!$this->_validateSubdomain(trim($sub_domains[$i]))) return false; } @@ -751,12 +752,12 @@ * @param string $subdomain The string to check. * @return boolean Success or failure. */ - function validateSubdomain($subdomain) + function _validateSubdomain($subdomain) { if (preg_match('|^\[(.*)]$|', $subdomain, $arr)){ - if (!$this->validateDliteral($arr[1])) return false; + if (!$this->_validateDliteral($arr[1])) return false; } else { - if (!$this->validateAtom($subdomain)) return false; + if (!$this->_validateAtom($subdomain)) return false; } // Got here, so return successful. @@ -771,7 +772,7 @@ * @param string $dliteral The string to check. * @return boolean Success or failure. */ - function validateDliteral($dliteral) + function _validateDliteral($dliteral) { return !preg_match('/(.)[][\x0D\\\\]/', $dliteral, $matches) && $matches[1] != '\\'; } @@ -785,14 +786,14 @@ * @param string $addr_spec The string to check. * @return mixed False on failure, or the validated addr-spec on success. */ - function validateAddrSpec($addr_spec) + function _validateAddrSpec($addr_spec) { $addr_spec = trim($addr_spec); // Split on @ sign if there is one. if (strpos($addr_spec, '@') !== false) { $parts = explode('@', $addr_spec); - $local_part = $this->splitCheck($parts, '@'); + $local_part = $this->_splitCheck($parts, '@'); $domain = substr($addr_spec, strlen($local_part . '@')); // No @ sign so assume the default domain. @@ -801,8 +802,8 @@ $domain = $this->default_domain; } - if (($local_part = $this->validateLocalPart($local_part)) === false) return false; - if (($domain = $this->validateDomain($domain)) === false) return false; + if (($local_part = $this->_validateLocalPart($local_part)) === false) return false; + if (($domain = $this->_validateDomain($domain)) === false) return false; // Got here so return successful. return array('local_part' => $local_part, 'domain' => $domain); @@ -816,13 +817,13 @@ * @param string $local_part * @return mixed False on failure, or the validated local part on success. */ - function validateLocalPart($local_part) + function _validateLocalPart($local_part) { $parts = explode('.', $local_part); // Split the local_part into words. while (count($parts) > 0){ - $words[] = $this->splitCheck($parts, '.'); + $words[] = $this->_splitCheck($parts, '.'); for ($i = 0; $i < $this->index + 1; $i++) { array_shift($parts); } @@ -830,7 +831,7 @@ // Validate each word. for ($i = 0; $i < count($words); $i++) { - if ($this->validatePhrase(trim($words[$i])) === false) return false; + if ($this->_validatePhrase(trim($words[$i])) === false) return false; } // Managed to get here, so return the input.