Merge branch 'smtputf8' of https://github.com/jprjr/roundcubemail into jprjr-smtputf8

pull/6116/head
Aleksander Machniak 7 years ago
commit 5665344673

@ -226,15 +226,31 @@ class rcube_smtp
return false; return false;
} }
// RFC3461: Delivery Status Notification
if ($opts['dsn']) {
$exts = $this->conn->getServiceExtensions(); $exts = $this->conn->getServiceExtensions();
// RFC3461: Delivery Status Notification
if ($opts['dsn']) {
if (isset($exts['DSN'])) { if (isset($exts['DSN'])) {
$from_params = 'RET=HDRS'; $from_params = 'RET=HDRS';
$recipient_params = 'NOTIFY=SUCCESS,FAILURE'; $recipient_params = 'NOTIFY=SUCCESS,FAILURE';
} }
} }
//RFC6531: request smtputf8 if needed
if (
!mb_check_encoding($from,'ASCII') ||
!mb_check_encoding($recipients,'ASCII')
) {
if (isset($exts['SMTPUTF8'])) {
if (!empty($from_params)) {
$from_params .= ' ';
}
$from_params .= 'SMTPUTF8';
}
else {
return false;
}
}
// RFC2298.3: remove envelope sender address // RFC2298.3: remove envelope sender address
if (empty($opts['mdn_use_from']) if (empty($opts['mdn_use_from'])

@ -64,7 +64,7 @@ class rcube_utils
public static function check_email($email, $dns_check=true) public static function check_email($email, $dns_check=true)
{ {
// Check for invalid characters // Check for invalid characters
if (preg_match('/[\x00-\x1F\x7F-\xFF]/', $email)) { if (preg_match('/\p{Cc}/u', $email)) {
return false; return false;
} }
@ -83,15 +83,31 @@ class rcube_utils
$domain_part = array_pop($email_array); $domain_part = array_pop($email_array);
$local_part = implode('@', $email_array); $local_part = implode('@', $email_array);
// from PEAR::Validate // XXX RFC states that ".." is not allowed in a local-part
$regexp = '&^(?: // of an email address, but apparently gmail allows it.
("\s*(?:[^"\f\n\r\t\v\b\s]+\s*)+")| #1 quoted name if(preg_match('/^\.|\.$/',$local_part)) {
([-\w!\#\$%\&\'*+~/^`|{}=]+(?:\.[-\w!\#\$%\&\'*+~/^`|{}=]+)*)) #2 OR dot-atom (RFC5322) return false;
$&xi'; }
$local_subparts;
preg_match_all('/"(?:\\\\.|[^\\\\"])*"|[^\.]+/',$local_part,$local_subparts);
if (!preg_match($regexp, $local_part)) { foreach ($local_subparts[0] as $l) {
if(substr($l,0,1) == '"') {
// quoted-string, make sure all backslashes and quotes are
// escaped
$local_quoted = preg_replace('/\\\\(\\\\|\")/','',substr($l,1,-1));
if(preg_match('/\\\\|"/',$local_quoted)) {
return false; return false;
} }
}
else {
// dot-atom portion, make sure there's no prohibited characters
if(preg_match('/[\\ ",:;<>@]/',$l)) {
return false;
}
}
}
// Validate domain part // Validate domain part
if (preg_match('/^\[((IPv6:[0-9a-f:.]+)|([0-9.]+))\]$/i', $domain_part, $matches)) { if (preg_match('/^\[((IPv6:[0-9a-f:.]+)|([0-9.]+))\]$/i', $domain_part, $matches)) {

Loading…
Cancel
Save