From 2c200021fdf9b5d1c73e39e7c46e7db1e4152e91 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Mon, 15 Nov 2010 04:26:24 -0500
Subject: [PATCH] - Fix focused elements aren't unfocused when clicking on the list (#1487123)

---
 program/js/common.js |   30 +++++++++++++++++-------------
 1 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/program/js/common.js b/program/js/common.js
index 4e98347..76ddd72 100644
--- a/program/js/common.js
+++ b/program/js/common.js
@@ -484,21 +484,25 @@
 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
+      //domain_literal = '\\x5b('+dtext+'|'+quoted_pair+')*\\x5d',
+      //sub_domain = '('+atom+'|'+domain_literal+')',
+      domain = '([^@\\x2e]+\\x2e)+[a-z]{2,}',
+      word = '('+atom+'|'+quoted_string+')',
+      delim = '[,;\s\n]',
+      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;
 };
 

--
Gitblit v1.9.1