summaryrefslogtreecommitdiff
path: root/program/steps/settings/save_identity.inc
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2010-09-29 12:36:28 +0000
committeralecpl <alec@alec.pl>2010-09-29 12:36:28 +0000
commite99991996dbb9e7b0b0ff6cfa94dc0fb2522eb66 (patch)
tree8031feaef48d8d30de1253318993f8c0a2223674 /program/steps/settings/save_identity.inc
parentd7f9eb573b82ca55c521b68f7cf3ad8de55ab8ba (diff)
- Add Internationalized Domain Name (IDNA) support (#1483894)
Diffstat (limited to 'program/steps/settings/save_identity.inc')
-rw-r--r--program/steps/settings/save_identity.inc25
1 files changed, 24 insertions, 1 deletions
diff --git a/program/steps/settings/save_identity.inc b/program/steps/settings/save_identity.inc
index 895ddea62..313e9df4d 100644
--- a/program/steps/settings/save_identity.inc
+++ b/program/steps/settings/save_identity.inc
@@ -56,6 +56,18 @@ foreach ($a_boolean_cols as $col)
if (IDENTITIES_LEVEL == 1 || IDENTITIES_LEVEL == 3)
unset($save_data['email']);
+// Validate e-mail addresses
+foreach (array('email', 'reply-to', 'bcc') as $item) {
+ if ($email = $save_data[$item]) {
+ $ascii_email = idn_to_ascii($email);
+ if (!check_email($ascii_email, false)) {
+ // show error message
+ $OUTPUT->show_message('emailformaterror', 'error', array('email' => $email), false);
+ rcmail_overwrite_action('edit-identity');
+ return;
+ }
+ }
+}
// update an existing contact
if ($_POST['_iid'])
@@ -64,6 +76,13 @@ if ($_POST['_iid'])
$plugin = $RCMAIL->plugins->exec_hook('identity_update', array('id' => $iid, 'record' => $save_data));
$save_data = $plugin['record'];
+ if ($save_data['email'])
+ $save_data['email'] = idn_to_ascii($save_data['email']);
+ if ($save_data['bcc'])
+ $save_data['bcc'] = idn_to_ascii($save_data['bcc']);
+ if ($save_data['reply-to'])
+ $save_data['reply-to'] = idn_to_ascii($save_data['reply-to']);
+
if (!$plugin['abort'] && ($updated = $USER->update_identity($iid, $save_data)))
{
$OUTPUT->show_message('successfullysaved', 'confirmation');
@@ -74,7 +93,7 @@ if ($_POST['_iid'])
if ($_POST['_framed'])
{
// update the changed col in list
- // ...
+ // ...
}
}
else if ($plugin['abort'] || $DB->is_error())
@@ -95,6 +114,10 @@ else if (IDENTITIES_LEVEL < 2)
$plugin = $RCMAIL->plugins->exec_hook('identity_create', array('record' => $save_data));
$save_data = $plugin['record'];
+ $save_data['email'] = idn_to_ascii($save_data['email']);
+ $save_data['bcc'] = idn_to_ascii($save_data['bcc']);
+ $save_data['reply-to'] = idn_to_ascii($save_data['reply-to']);
+
if (!$plugin['abort'] && $save_data['email'] && ($insert_id = $USER->insert_identity($save_data)))
{
$OUTPUT->show_message('successfullysaved', 'confirmation', null, false);