Better patch to correctly quote email recipient strings (from #1484191)
| | |
| | | function format_email_recipient($email, $name='') |
| | | { |
| | | if ($name && $name != $email) |
| | | return sprintf('%s <%s>', strpos($name, ",") ? '"'.$name.'"' : $name, $email); |
| | | { |
| | | // Special chars as defined by RFC 822 need to in quoted string (or escaped). |
| | | return sprintf('%s <%s>', preg_match('/[\(\)\<\>\\\.\[\]@,;:"]/', $name) ? '"'.addcslashes($name, '"').'"' : $name, $email); |
| | | } |
| | | else |
| | | return $email; |
| | | } |
| | |
| | | { |
| | | $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) |
| | |
| | | { |
| | | while ($sql_arr = $result->iterate()) |
| | | if ($sql_arr['email']) |
| | | $a_contacts[] = format_email_recipient($sql_arr['email'], JQ($sql_arr['name'])); |
| | | $a_contacts[] = format_email_recipient($sql_arr['email'], $sql_arr['name']); |
| | | } |
| | | if (isset($CONFIG['ldap_public'])) |
| | | { |
| | |
| | | $email = $results->records[$i]['email']; |
| | | $name = $results->records[$i]['name']; |
| | | |
| | | $a_contacts[] = format_email_recipient($email, JQ($name)); |
| | | $a_contacts[] = format_email_recipient($email, $name); |
| | | } |
| | | } |
| | | $LDAP->close(); |