Skip to content

Commit

Permalink
Catch Idna_Exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Feb 27, 2017
1 parent 3e187ef commit 1c07a71
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions imp/lib/Compose.php
Expand Up @@ -1275,12 +1275,12 @@ protected function _prepSendMessageEncode(Horde_Mail_Rfc822_List $email,
/* $email contains address objects that already have the default
* maildomain appended. Need to encode personal part and encode
* IDN domain names. */
$tmp = $val->writeAddress(array(
'encode' => $charset,
'idn' => true
));

try {
$tmp = $val->writeAddress(array(
'encode' => $charset,
'idn' => true
));

/* We have written address, but it still may not be valid.
* So double-check. */
$alist = IMP::parseAddressList($tmp, array(
Expand All @@ -1300,6 +1300,10 @@ protected function _prepSendMessageEncode(Horde_Mail_Rfc822_List $email,
$hook = false;
}
}
} catch (Horde_Idna_Exception $e) {
$error = array(
'msg' => sprintf(_("Invalid e-mail address (%s): %s"), $val, $e->getMessage())
);
} catch (Horde_Mail_Exception $e) {
$error = array(
'msg' => sprintf(_("Invalid e-mail address (%s)."), $val)
Expand Down

0 comments on commit 1c07a71

Please sign in to comment.