Changeset 6f09681 in github


Ignore:
Timestamp:
Nov 2, 2010 5:27:03 AM (3 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
a5e8e5d
Parents:
d366462
Message:
  • Support contact's email addresses up to 255 characters long (#1487095)
  • Added email format checks when saving contacts data
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    r9ae29c9 r6f09681  
    5959- Improve performance of setting IMAP flags using .SILENT suffix 
    6060- Improve performance of message cache status checking with skip_disabled=true 
     61- Support contact's email addresses up to 255 characters long (#1487095) 
    6162 
    6263RELEASE 0.4.2 
  • SQL/mssql.initial.sql

    race511a r6f09681  
    1414        [del] [char] (1) COLLATE Latin1_General_CI_AI NOT NULL , 
    1515        [name] [varchar] (128) COLLATE Latin1_General_CI_AI NOT NULL , 
    16         [email] [varchar] (128) COLLATE Latin1_General_CI_AI NOT NULL , 
     16        [email] [varchar] (255) COLLATE Latin1_General_CI_AI NOT NULL , 
    1717        [firstname] [varchar] (128) COLLATE Latin1_General_CI_AI NOT NULL , 
    1818        [surname] [varchar] (128) COLLATE Latin1_General_CI_AI NOT NULL , 
  • SQL/mssql.upgrade.sql

    race511a r6f09681  
    2323GO 
    2424 
    25 ALTER TABLE [dbo].[identities] add [changed] [datetime] NULL  
     25ALTER TABLE [dbo].[identities] ADD [changed] [datetime] NULL  
    2626GO 
    2727 
     
    9494CREATE UNIQUE INDEX [IX_users_username] ON [dbo].[users]([username],[mail_host]) ON [PRIMARY] 
    9595GO 
     96ALTER TABLE [dbo].[contacts] ALTER COLUMN [email] [varchar] (255) COLLATE Latin1_General_CI_AI NOT NULL 
     97GO 
    9698 
  • SQL/mysql.initial.sql

    race511a r6f09681  
    8484 `del` tinyint(1) NOT NULL DEFAULT '0', 
    8585 `name` varchar(128) NOT NULL DEFAULT '', 
    86  `email` varchar(128) NOT NULL, 
     86 `email` varchar(255) NOT NULL, 
    8787 `firstname` varchar(128) NOT NULL DEFAULT '', 
    8888 `surname` varchar(128) NOT NULL DEFAULT '', 
  • SQL/mysql.update.sql

    race511a r6f09681  
    130130ALTER TABLE `users` ADD UNIQUE `username` (`username`, `mail_host`); 
    131131 
     132ALTER TABLE `contacts` MODIFY `email` varchar(255) NOT NULL; 
     133 
  • SQL/postgres.initial.sql

    race511a r6f09681  
    108108    del smallint DEFAULT 0 NOT NULL, 
    109109    name varchar(128) DEFAULT '' NOT NULL, 
    110     email varchar(128) DEFAULT '' NOT NULL, 
     110    email varchar(255) DEFAULT '' NOT NULL, 
    111111    firstname varchar(128) DEFAULT '' NOT NULL, 
    112112    surname varchar(128) DEFAULT '' NOT NULL, 
  • SQL/postgres.update.sql

    race511a r6f09681  
    8787DROP INDEX users_username_id_idx; 
    8888ALTER TABLE users ADD UNIQUE (username, mail_host); 
     89ALTER TABLE contacts ALTER email TYPE varchar(255); 
    8990 
  • SQL/sqlite.initial.sql

    race511a r6f09681  
    2929  del tinyint NOT NULL default '0', 
    3030  name varchar(128) NOT NULL default '', 
    31   email varchar(128) NOT NULL default '', 
     31  email varchar(255) NOT NULL default '', 
    3232  firstname varchar(128) NOT NULL default '', 
    3333  surname varchar(128) NOT NULL default '', 
  • SQL/sqlite.update.sql

    race511a r6f09681  
    147147CREATE UNIQUE INDEX ix_users_username ON users(username, mail_host); 
    148148 
     149CREATE TABLE contacts_tmp ( 
     150    contact_id integer NOT NULL PRIMARY KEY, 
     151    user_id integer NOT NULL default '0', 
     152    changed datetime NOT NULL default '0000-00-00 00:00:00', 
     153    del tinyint NOT NULL default '0', 
     154    name varchar(128) NOT NULL default '', 
     155    email varchar(255) NOT NULL default '', 
     156    firstname varchar(128) NOT NULL default '', 
     157    surname varchar(128) NOT NULL default '', 
     158    vcard text NOT NULL default '' 
     159); 
     160 
     161INSERT INTO contacts_tmp (contact_id, user_id, changed, del, name, email, firstname, surname, vcard) 
     162    SELECT contact_id, user_id, changed, del, name, email, firstname, surname, vcard FROM contacts; 
     163 
     164DROP TABLE contacts; 
     165CREATE TABLE contacts ( 
     166    contact_id integer NOT NULL PRIMARY KEY, 
     167    user_id integer NOT NULL default '0', 
     168    changed datetime NOT NULL default '0000-00-00 00:00:00', 
     169    del tinyint NOT NULL default '0', 
     170    name varchar(128) NOT NULL default '', 
     171    email varchar(255) NOT NULL default '', 
     172    firstname varchar(128) NOT NULL default '', 
     173    surname varchar(128) NOT NULL default '', 
     174    vcard text NOT NULL default '' 
     175); 
     176 
     177INSERT INTO contacts (contact_id, user_id, changed, del, name, email, firstname, surname, vcard) 
     178    SELECT contact_id, user_id, changed, del, name, email, firstname, surname, vcard FROM contacts_tmp; 
     179 
     180CREATE INDEX ix_contacts_user_id ON contacts(user_id, email); 
     181DROP TABLE contacts_tmp; 
     182 
  • program/js/common.js

    re999919 r6f09681  
    492492      // Use simplified domain matching, because we need to allow Unicode characters here 
    493493      // So, e-mail address should be validated also on server side after idn_to_ascii() use 
    494       sub_domain = '[^@]+', 
    495494      //domain_literal = '\\x5b('+dtext+'|'+quoted_pair+')*\\x5d', 
    496495      //sub_domain = '('+atom+'|'+domain_literal+')', 
     496      domain = '([^@\\x2e]+\\x2e)+[a-z]{2,}', 
    497497      word = '('+atom+'|'+quoted_string+')', 
    498498      delim = '[,;\s\n]', 
    499       domain = sub_domain+'(\\x2e'+sub_domain+')*', 
    500499      local_part = word+'(\\x2e'+word+')*', 
    501500      addr_spec = local_part+'\\x40'+domain, 
  • program/steps/addressbook/save.inc

    rce92ba7 r6f09681  
    2121 
    2222$cid = get_input_value('_cid', RCUBE_INPUT_POST); 
    23 $return_action = empty($cid) ? 'add' : 'show'; 
     23$return_action = empty($cid) ? 'add' : 'edit'; 
    2424 
    2525// cannot edit record 
    26 if ($CONTACTS->readonly) 
    27 { 
     26if ($CONTACTS->readonly) { 
    2827  $OUTPUT->show_message('contactreadonly', 'error'); 
    2928  rcmail_overwrite_action($return_action); 
     
    3130} 
    3231 
    33 // check input 
    34 if ((!get_input_value('_name', RCUBE_INPUT_POST) || !get_input_value('_email', RCUBE_INPUT_POST))) 
    35 { 
     32// Basic input checks 
     33if ((!get_input_value('_name', RCUBE_INPUT_POST) || !get_input_value('_email', RCUBE_INPUT_POST))) { 
    3634  $OUTPUT->show_message('formincomplete', 'warning'); 
    3735  rcmail_overwrite_action($return_action); 
     
    4543 
    4644// read POST values into hash array 
    47 foreach ($a_save_cols as $col) 
    48 { 
     45foreach ($a_save_cols as $col) { 
    4946  $fname = '_'.$col; 
    5047  if (isset($_POST[$fname])) 
    5148    $a_record[$col] = get_input_value($fname, RCUBE_INPUT_POST); 
     49} 
     50 
     51// Validity checks 
     52$_email = idn_to_ascii($a_record['email']); 
     53if (!check_email($_email, false)) { 
     54  $OUTPUT->show_message('emailformaterror', 'warning', array('email' => $_email)); 
     55  rcmail_overwrite_action($return_action); 
     56  return; 
    5257} 
    5358 
     
    5863    array('id' => $cid, 'record' => $a_record, 'source' => get_input_value('_source', RCUBE_INPUT_GPC))); 
    5964  $a_record = $plugin['record']; 
    60    
     65 
    6166  if (!$plugin['abort']) 
    6267    $result = $CONTACTS->update($cid, $a_record); 
     
    7176      $_POST['_cid'] = $newcid; 
    7277    } 
    73      
     78 
    7479    // define list of cols to be displayed 
    7580    $a_js_cols = array(); 
     
    8186    // update the changed col in list 
    8287    $OUTPUT->command('parent.update_contact_row', $cid, $a_js_cols, $newcid); 
    83        
     88 
    8489    // show confirmation 
    8590    $OUTPUT->show_message('successfullysaved', 'confirmation', null, false); 
  • program/steps/mail/addcontact.inc

    rce92ba7 r6f09681  
    3030{ 
    3131  $contact_arr = $IMAP->decode_address_list(get_input_value('_address', RCUBE_INPUT_POST, true), 1, false); 
    32    
     32 
    3333  if (!empty($contact_arr[1]['mailto'])) { 
    3434    $contact = array( 
     
    3636      'name' => $contact_arr[1]['name'] 
    3737    ); 
     38 
     39    // Validity checks 
     40    if (empty($contact['email'])) { 
     41      $OUTPUT->show_message('errorsavingcontact', 'error'); 
     42      $OUTPUT->send(); 
     43    } 
     44    else if (!check_email($contact['email'], false)) { 
     45      $OUTPUT->show_message('emailformaterror', 'error', array('email' => $contact['email'])); 
     46      $OUTPUT->send(); 
     47    } 
    3848 
    3949    $contact['email'] = idn_to_utf8($contact['email']); 
     
    6171 
    6272if (!$done) 
    63   $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsavingcontact', 'warning'); 
     73  $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsavingcontact', 'error'); 
    6474 
    6575$OUTPUT->send(); 
Note: See TracChangeset for help on using the changeset viewer.