diff options
author | thomascube <thomas@roundcube.net> | 2007-11-30 17:20:16 +0000 |
---|---|---|
committer | thomascube <thomas@roundcube.net> | 2007-11-30 17:20:16 +0000 |
commit | f20cf0f1711fe7a4084f76754b7381176b8a765e (patch) | |
tree | 390194b406c5a5e0aef4e70383639c530c5719ca /program/js | |
parent | ed54070eb5c942e9745efd7ad57a4ff02deeaf04 (diff) |
Simplified email address check (fixes #1484679)
Diffstat (limited to 'program/js')
-rw-r--r-- | program/js/app.js | 2 | ||||
-rw-r--r-- | program/js/common.js | 57 |
2 files changed, 13 insertions, 46 deletions
diff --git a/program/js/app.js b/program/js/app.js index 9bb85689a..7162795fe 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -1674,7 +1674,7 @@ function rcube_webmail() var input_message = rcube_find_object('_message'); // check for empty recipient - if (input_to && !rcube_check_email(input_to.value, true)) + if (input_to && !rcube_check_email(input_to.value.replace(/^\s+/, '').replace(/[\s,;]+$/, ''), true)) { alert(this.get_label('norecipientwarning')); input_to.focus(); diff --git a/program/js/common.js b/program/js/common.js index da1c09225..fb49bfbbe 100644 --- a/program/js/common.js +++ b/program/js/common.js @@ -396,51 +396,18 @@ function rcube_check_email(input, inline) { if (input && window.RegExp) { - var no_ws_ctl = "[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]"; - var alpha = "[\\x41-\\x5a\\x61-\\x7a]"; - var digit = "[\\x30-\\x39]"; - var cr = "\\x0d"; - var lf = "\\x0a"; - var crlf = "(" + cr + lf + ")"; - - var obs_char = "[\\x00-\\x09\\x0b\\x0c\\x0e-\\x7f]"; - var obs_text = "("+lf+"*"+cr+"*("+obs_char+lf+"*"+cr+"*)*)"; - var text = "([\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f]|"+obs_text+")"; - var obs_qp = "(\\x5c[\\x00-\\x7f])"; - var quoted_pair = "(\\x5c"+text+"|"+obs_qp+")"; - - var wsp = "[\\x20\\x09]"; - var obs_fws = "("+wsp+"+("+crlf+wsp+"+)*)"; - var fws = "((("+wsp+"*"+crlf+")?"+wsp+"+)|"+obs_fws+")"; - var ctext = "("+no_ws_ctl+"|[\\x21-\\x27\\x2A-\\x5b\\x5d-\\x7e])"; - var ccontent = "("+ctext+"|"+quoted_pair+")"; - var comment = "(\\x28("+fws+"?"+ccontent+")*"+fws+"?\\x29)"; - var cfws = "(("+fws+"?"+comment+")*("+fws+"?"+comment+"|"+fws+"))"; - var cfws = fws+"*"; - - var atext = "("+alpha+"|"+digit+"|[\\x21\\x23-\\x27\\x2a\\x2b\\x2d\\x2e\\x3d\\x3f\\x5e\\x5f\\x60\\x7b-\\x7e])"; - var atom = "("+cfws+"?"+atext+"+"+cfws+"?)"; - - var qtext = "("+no_ws_ctl+"|[\\x21\\x23-\\x5b\\x5d-\\x7e])"; - var qcontent = "("+qtext+"|"+quoted_pair+")"; - var quoted_string = "("+cfws+"?\\x22("+fws+"?"+qcontent+")*"+fws+"?\\x22"+cfws+"?)"; - var word = "("+atom+"|"+quoted_string+")"; - - var obs_local_part = "("+word+"(\\x2e"+word+")*)"; - var obs_domain = "("+atom+"(\\x2e"+atom+")*)"; - - var dot_atom_text = "("+atext+"+(\\x2e"+atext+"+)*)"; - var dot_atom = "("+cfws+"?"+dot_atom_text+cfws+"?)"; - - var dtext = "("+no_ws_ctl+"|[\\x21-\\x5a\\x5e-\\x7e])"; - var dcontent = "("+dtext+"|"+quoted_pair+")"; - var domain_literal = "("+cfws+"?\\x5b("+fws+"?"+dcontent+")*"+fws+"?\\x5d"+cfws+"?)"; - - var local_part = "("+dot_atom+"|"+quoted_string+"|"+obs_local_part+")"; - var domain = "("+dot_atom+"|"+domain_literal+"|"+obs_domain+")"; - var addr_spec = "("+local_part+"\\x40"+domain+")"; - - var reg1 = inline ? new RegExp(addr_spec, 'i') : new RegExp('^'+addr_spec+'$', 'i'); + var qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]'; + var dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]'; + var atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+'; + var quoted_pair = '\\x5c[\\x00-\\x7f]'; + var domain_literal = '\\x5b('+dtext+'|'+quoted_pair+')*\\x5d'; + var quoted_string = '\\x22('+qtext+'|'+quoted_pair+')*\\x22'; + var sub_domain = '('+atom+'|'+domain_literal+')'; + var word = '('+atom+'|'+quoted_string+')'; + var domain = sub_domain+'(\\x2e'+sub_domain+')*'; + var local_part = word+'(\\x2e'+word+')*'; + var addr_spec = local_part+'\\x40'+domain; + var reg1 = inline ? new RegExp('(^|<)'+addr_spec+'(>|$)', 'i') : new RegExp('^'+addr_spec+'$', 'i'); return reg1.test(input) ? true : false; } return false; |