| | |
| | | { |
| | | $a = $this->_parse_address_list($input, $decode); |
| | | $out = array(); |
| | | // Special chars as defined by RFC 822 need to in quoted string (or escaped). |
| | | $special_chars = '[\(\)\<\>\\\.\[\]@,;:"]'; |
| | | |
| | | if (!is_array($a)) |
| | | return $out; |
| | |
| | | $address = $val['address']; |
| | | $name = preg_replace(array('/^[\'"]/', '/[\'"]$/'), '', trim($val['name'])); |
| | | if ($name && $address && $name != $address) |
| | | $string = sprintf('%s <%s>', preg_match('/[,;<>]/', $name) ? '"'.addcslashes($name, '"').'"' : $name, $address); |
| | | $string = sprintf('%s <%s>', preg_match("/$special_chars/", $name) ? '"'.addcslashes($name, '"').'"' : $name, $address); |
| | | else if ($address) |
| | | $string = $address; |
| | | else if ($name) |