Support both comma and semicolon as recipient separator, drop recipients_separator option (#5092)

pull/5815/head
Aleksander Machniak 8 years ago
parent bcc6405552
commit 6dee73a0ec

@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail CHANGELOG Roundcube Webmail
=========================== ===========================
- Support both comma and semicolon as recipient separator, drop recipients_separator option (#5092)
- Plugin API: Added 'show_bytes' hook (#5001) - Plugin API: Added 'show_bytes' hook (#5001)
- subscriptions_option: show \\Noselect folders greyed out (#5621) - subscriptions_option: show \\Noselect folders greyed out (#5621)
- Add option to not indent quoted text on top-posting reply (#5105) - Add option to not indent quoted text on top-posting reply (#5105)

@ -761,9 +761,6 @@ $config['spellcheck_ignore_nums'] = false;
// Makes that words with symbols will be ignored (e.g. g@@gle) // Makes that words with symbols will be ignored (e.g. g@@gle)
$config['spellcheck_ignore_syms'] = false; $config['spellcheck_ignore_syms'] = false;
// Use this char/string to separate recipients when composing a new message
$config['recipients_separator'] = ',';
// Number of lines at the end of a message considered to contain the signature. // Number of lines at the end of a message considered to contain the signature.
// Increase this value if signatures are not properly detected and colored // Increase this value if signatures are not properly detected and colored
$config['sig_max_lines'] = 15; $config['sig_max_lines'] = 15;

@ -58,8 +58,8 @@ function rcube_webmail()
request_timeout: 180, // seconds request_timeout: 180, // seconds
draft_autosave: 0, // seconds draft_autosave: 0, // seconds
comm_path: './', comm_path: './',
recipients_separator: ',', recipients_separator: ',', // @deprecated
recipients_delimiter: ', ', recipients_delimiter: ', ', // @deprecated
popup_width: 1150, popup_width: 1150,
popup_width_small: 900 popup_width_small: 900
}; };
@ -4299,8 +4299,6 @@ function rcube_webmail()
this.init_address_input_events = function(obj, props) this.init_address_input_events = function(obj, props)
{ {
this.env.recipients_delimiter = this.env.recipients_separator + ' ';
obj.keydown(function(e) { return ref.ksearch_keydown(e, this, props); }) obj.keydown(function(e) { return ref.ksearch_keydown(e, this, props); })
.attr({ 'autocomplete': 'off', 'aria-autocomplete': 'list', 'aria-expanded': 'false', 'role': 'combobox' }); .attr({ 'autocomplete': 'off', 'aria-autocomplete': 'list', 'aria-expanded': 'false', 'role': 'combobox' });
@ -4377,7 +4375,7 @@ function rcube_webmail()
field = field.length ? field.attr('id').replace('_', '') : 'to'; field = field.length ? field.attr('id').replace('_', '') : 'to';
} }
var recipients = [], input = $('#_'+field), delim = this.env.recipients_delimiter; var recipients = [], input = $('#_' + field);
if (this.contact_list && this.contact_list.selection.length) { if (this.contact_list && this.contact_list.selection.length) {
for (var id, n=0; n < this.contact_list.selection.length; n++) { for (var id, n=0; n < this.contact_list.selection.length; n++) {
@ -4396,10 +4394,10 @@ function rcube_webmail()
} }
if (recipients.length && input.length) { if (recipients.length && input.length) {
var oldval = input.val(), rx = new RegExp(RegExp.escape(delim) + '\\s*$'); var oldval = input.val();
if (oldval && !rx.test(oldval)) if (oldval && !/[,;]\s*$/.test(oldval))
oldval += delim + ' '; oldval += ', ';
input.val(oldval + recipients.join(delim + ' ') + delim + ' ').change(); input.val(oldval + recipients.join(', ') + ', ').change();
this.triggerEvent('add-recipient', { field:field, recipients:recipients }); this.triggerEvent('add-recipient', { field:field, recipients:recipients });
} }
@ -4885,9 +4883,7 @@ function rcube_webmail()
show_sig = this.env.show_sig; show_sig = this.env.show_sig;
var id = obj.options[obj.selectedIndex].value, var id = obj.options[obj.selectedIndex].value,
sig = this.env.identity, sig = this.env.identity;
delim = this.env.recipients_separator,
rx_delim = RegExp.escape(delim);
// enable manual signature insert // enable manual signature insert
if (this.env.signatures && this.env.signatures[id]) { if (this.env.signatures && this.env.signatures[id]) {
@ -4920,19 +4916,15 @@ function rcube_webmail()
} }
// cleanup // cleanup
rx = new RegExp(rx_delim + '\\s*' + rx_delim, 'g'); input_val = String(input_val).replace(/[,;]\s*[,;]/g, ',').replace(/^[\s,;]+/, '');
input_val = String(input_val).replace(rx, delim);
rx = new RegExp('^[\\s' + rx_delim + ']+');
input_val = input_val.replace(rx, '');
// add new address(es) // add new address(es)
if (new_val && input_val.indexOf(new_val) == -1 && input_val.indexOf(new_val.replace(/"/g, '')) == -1) { if (new_val && input_val.indexOf(new_val) == -1 && input_val.indexOf(new_val.replace(/"/g, '')) == -1) {
if (input_val) { if (input_val) {
rx = new RegExp('[' + rx_delim + '\\s]+$') input_val = input_val.replace(/[,;\s]+$/, '') + ', ';
input_val = input_val.replace(rx, '') + delim + ' ';
} }
input_val += new_val + delim + ' '; input_val += new_val + ', ';
} }
if (old_val || new_val) if (old_val || new_val)
@ -5469,6 +5461,7 @@ function rcube_webmail()
p = inp_value.lastIndexOf(this.ksearch_value, cpos), p = inp_value.lastIndexOf(this.ksearch_value, cpos),
trigger = false, trigger = false,
insert = '', insert = '',
delim = ', ',
// replace search string with full address // replace search string with full address
pre = inp_value.substring(0, p), pre = inp_value.substring(0, p),
end = inp_value.substring(p+this.ksearch_value.length, inp_value.length); end = inp_value.substring(p+this.ksearch_value.length, inp_value.length);
@ -5477,16 +5470,16 @@ function rcube_webmail()
// insert all members of a group // insert all members of a group
if (typeof this.env.contacts[id] === 'object' && this.env.contacts[id].type == 'group' && !this.env.contacts[id].email) { if (typeof this.env.contacts[id] === 'object' && this.env.contacts[id].type == 'group' && !this.env.contacts[id].email) {
insert += this.env.contacts[id].name + this.env.recipients_delimiter; insert += this.env.contacts[id].name + delim;
this.group2expand[this.env.contacts[id].id] = $.extend({ input: this.ksearch_input }, this.env.contacts[id]); this.group2expand[this.env.contacts[id].id] = $.extend({ input: this.ksearch_input }, this.env.contacts[id]);
this.http_request('mail/group-expand', {_source: this.env.contacts[id].source, _gid: this.env.contacts[id].id}, false); this.http_request('mail/group-expand', {_source: this.env.contacts[id].source, _gid: this.env.contacts[id].id}, false);
} }
else if (typeof this.env.contacts[id] === 'object' && this.env.contacts[id].name) { else if (typeof this.env.contacts[id] === 'object' && this.env.contacts[id].name) {
insert = this.env.contacts[id].name + this.env.recipients_delimiter; insert = this.env.contacts[id].name + delim;
trigger = true; trigger = true;
} }
else if (typeof this.env.contacts[id] === 'string') { else if (typeof this.env.contacts[id] === 'string') {
insert = this.env.contacts[id] + this.env.recipients_delimiter; insert = this.env.contacts[id] + delim;
trigger = true; trigger = true;
} }
@ -5524,10 +5517,9 @@ function rcube_webmail()
if (this.ksearch_pane && this.ksearch_pane.is(":visible")) if (this.ksearch_pane && this.ksearch_pane.is(":visible"))
this.ksearch_pane.hide(); this.ksearch_pane.hide();
// get string from current cursor pos to last comma // get string from cursor position back to the last comma or semicolon
var cpos = this.get_caret_pos(this.ksearch_input), var cpos = this.get_caret_pos(this.ksearch_input),
p = inp_value.lastIndexOf(this.env.recipients_separator, cpos-1), q = inp_value.substr(0, cpos).split(/[,;]/).pop(),
q = inp_value.substring(p+1, cpos),
min = this.env.autocomplete_min_length, min = this.env.autocomplete_min_length,
data = this.ksearch_data; data = this.ksearch_data;

@ -26,7 +26,6 @@ if ($RCMAIL->action == 'group-expand') {
$abook->set_group($gid); $abook->set_group($gid);
$abook->set_pagesize(9999); // TODO: limit number of group members by config? $abook->set_pagesize(9999); // TODO: limit number of group members by config?
$separator = trim($RCMAIL->config->get('recipients_separator', ',')) . ' ';
$result = $abook->list_records($RCMAIL->config->get('contactlist_fields')); $result = $abook->list_records($RCMAIL->config->get('contactlist_fields'));
$members = array(); $members = array();
@ -37,7 +36,7 @@ if ($RCMAIL->action == 'group-expand') {
} }
} }
$OUTPUT->command('replace_group_recipients', $gid, join($separator, array_unique($members))); $OUTPUT->command('replace_group_recipients', $gid, join(', ', array_unique($members)));
} }
$OUTPUT->send(); $OUTPUT->send();

@ -98,7 +98,6 @@ $OUTPUT->set_env('session_id', session_id());
$OUTPUT->set_env('mailbox', $RCMAIL->storage->get_folder()); $OUTPUT->set_env('mailbox', $RCMAIL->storage->get_folder());
$OUTPUT->set_env('top_posting', intval($RCMAIL->config->get('reply_mode')) > 0); $OUTPUT->set_env('top_posting', intval($RCMAIL->config->get('reply_mode')) > 0);
$OUTPUT->set_env('sig_below', $RCMAIL->config->get('sig_below')); $OUTPUT->set_env('sig_below', $RCMAIL->config->get('sig_below'));
$OUTPUT->set_env('recipients_separator', trim($RCMAIL->config->get('recipients_separator', ',')));
$OUTPUT->set_env('save_localstorage', (bool)$RCMAIL->config->get('compose_save_localstorage')); $OUTPUT->set_env('save_localstorage', (bool)$RCMAIL->config->get('compose_save_localstorage'));
$OUTPUT->set_env('max_disclosed_recipients', (int) $RCMAIL->config->get('max_disclosed_recipients', 5)); $OUTPUT->set_env('max_disclosed_recipients', (int) $RCMAIL->config->get('max_disclosed_recipients', 5));
$OUTPUT->set_env('is_sent', false); $OUTPUT->set_env('is_sent', false);
@ -566,7 +565,7 @@ function rcmail_compose_header_value($header)
$fvalue = ''; $fvalue = '';
$decode_header = true; $decode_header = true;
$charset = $MESSAGE->headers->charset; $charset = $MESSAGE->headers->charset;
$separator = trim($RCMAIL->config->get('recipients_separator', ',')) . ' '; $separator = ', ';
// we have a set of recipients stored is session // we have a set of recipients stored is session
if ($header == 'to' && ($mailto_id = $COMPOSE['param']['mailto']) if ($header == 'to' && ($mailto_id = $COMPOSE['param']['mailto'])

@ -864,13 +864,13 @@ function rcmail_email_input_format($mailto, $count=false, $check=true)
// simplified email regexp, supporting quoted local part // simplified email regexp, supporting quoted local part
$email_regexp = '(\S+|("[^"]+"))@\S+'; $email_regexp = '(\S+|("[^"]+"))@\S+';
$delim = trim($RCMAIL->config->get('recipients_separator', ',')); $delim = ',;';
$regexp = array("/[,;$delim]\s*[\r\n]+/", '/[\r\n]+/', "/[,;$delim]\s*\$/m", '/;/', '/(\S{1})(<'.$email_regexp.'>)/U'); $regexp = array("/[$delim]\s*[\r\n]+/", '/[\r\n]+/', "/[$delim]\s*\$/m", '/;/', '/(\S{1})(<'.$email_regexp.'>)/U');
$replace = array($delim.' ', ', ', '', $delim, '\\1 \\2'); $replace = array(', ', ', ', '', ',', '\\1 \\2');
// replace new lines and strip ending ', ', make address input more valid // replace new lines and strip ending ', ', make address input more valid
$mailto = trim(preg_replace($regexp, $replace, $mailto)); $mailto = trim(preg_replace($regexp, $replace, $mailto));
$items = rcube_utils::explode_quoted_string($delim, $mailto); $items = rcube_utils::explode_quoted_string("[$delim]", $mailto);
$result = array(); $result = array();
foreach ($items as $item) { foreach ($items as $item) {

Loading…
Cancel
Save