diff options
author | alecpl <alec@alec.pl> | 2010-09-29 12:36:28 +0000 |
---|---|---|
committer | alecpl <alec@alec.pl> | 2010-09-29 12:36:28 +0000 |
commit | e99991996dbb9e7b0b0ff6cfa94dc0fb2522eb66 (patch) | |
tree | 8031feaef48d8d30de1253318993f8c0a2223674 /program/steps/settings | |
parent | d7f9eb573b82ca55c521b68f7cf3ad8de55ab8ba (diff) |
- Add Internationalized Domain Name (IDNA) support (#1483894)
Diffstat (limited to 'program/steps/settings')
-rw-r--r-- | program/steps/settings/edit_identity.inc | 4 | ||||
-rw-r--r-- | program/steps/settings/func.inc | 2 | ||||
-rw-r--r-- | program/steps/settings/save_identity.inc | 25 |
3 files changed, 29 insertions, 2 deletions
diff --git a/program/steps/settings/edit_identity.inc b/program/steps/settings/edit_identity.inc index 1a3df9555..d6af6e52c 100644 --- a/program/steps/settings/edit_identity.inc +++ b/program/steps/settings/edit_identity.inc @@ -94,6 +94,10 @@ function rcube_identity_form($attrib) $form['adressing']['content']['email']['class'] = 'disabled'; } + $IDENTITY_RECORD['email'] = idn_to_utf8($IDENTITY_RECORD['email']); + $IDENTITY_RECORD['reply-to'] = idn_to_utf8($IDENTITY_RECORD['reply-to']); + $IDENTITY_RECORD['bcc'] = idn_to_utf8($IDENTITY_RECORD['bcc']); + // Allow plugins to modify identity form content $plugin = $RCMAIL->plugins->exec_hook('identity_form', array( 'form' => $form, 'record' => $IDENTITY_RECORD)); diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc index 196a509c1..b03947845 100644 --- a/program/steps/settings/func.inc +++ b/program/steps/settings/func.inc @@ -72,7 +72,7 @@ function rcmail_identities_list($attrib) // get identities list and define 'mail' column $list = $USER->list_identities(); foreach ($list as $idx => $row) - $list[$idx]['mail'] = trim($row['name'] . ' <' . $row['email'] .'>'); + $list[$idx]['mail'] = trim($row['name'] . ' <' . idn_to_utf8($row['email']) .'>'); // get all identites from DB and define list of cols to be displayed $plugin = $RCMAIL->plugins->exec_hook('identities_list', array( 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); |