summaryrefslogtreecommitdiff
path: root/program/js/common.js
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/js/common.js
parentd7f9eb573b82ca55c521b68f7cf3ad8de55ab8ba (diff)
- Add Internationalized Domain Name (IDNA) support (#1483894)
Diffstat (limited to 'program/js/common.js')
-rw-r--r--program/js/common.js31
1 files changed, 18 insertions, 13 deletions
diff --git a/program/js/common.js b/program/js/common.js
index 4e98347f1..3a8739ba2 100644
--- a/program/js/common.js
+++ b/program/js/common.js
@@ -484,21 +484,26 @@ function rcube_layer(id, attributes)
function rcube_check_email(input, inline)
{
if (input && window.RegExp) {
- 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 delim = '[,;\s\n]';
- var reg1 = inline ? new RegExp('(^|<|'+delim+')'+addr_spec+'($|>|'+delim+')', 'i') : new RegExp('^'+addr_spec+'$', 'i');
+ var qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]',
+ dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]',
+ atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+',
+ quoted_pair = '\\x5c[\\x00-\\x7f]',
+ quoted_string = '\\x22('+qtext+'|'+quoted_pair+')*\\x22',
+ // Use simplified domain matching, because we need to allow Unicode characters here
+ // So, e-mail address should be validated also on server side after idn_to_ascii() use
+ sub_domain = '[^@]+',
+ //domain_literal = '\\x5b('+dtext+'|'+quoted_pair+')*\\x5d',
+ //sub_domain = '('+atom+'|'+domain_literal+')',
+ word = '('+atom+'|'+quoted_string+')',
+ delim = '[,;\s\n]',
+ domain = sub_domain+'(\\x2e'+sub_domain+')*',
+ local_part = word+'(\\x2e'+word+')*',
+ addr_spec = local_part+'\\x40'+domain,
+ reg1 = inline ? new RegExp('(^|<|'+delim+')'+addr_spec+'($|>|'+delim+')', 'i') : new RegExp('^'+addr_spec+'$', 'i');
+
return reg1.test(input) ? true : false;
}
+
return false;
};