Relaxed domain name validation for extended TLDs support (#5588)

pull/7195/head
Aleksander Machniak 5 years ago
parent 8793baa006
commit bdf0a6539e

@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail CHANGELOG Roundcube Webmail
=========================== ===========================
- Relaxed domain name validation for extended TLDs support (#5588)
- Added support for INSERT OR REPLACE queries (#6771) - Added support for INSERT OR REPLACE queries (#6771)
- Extract RFC2231 attachment name from message headers (#6729, #6783) - Extract RFC2231 attachment name from message headers (#6729, #6783)
- Managesieve: Allow display name with email address in vacation :from field (#6760) - Managesieve: Allow display name with email address in vacation :from field (#6760)

@ -425,8 +425,8 @@ function rcube_check_email(input, inline, count, strict)
// So, e-mail address should be validated also on server side after idn_to_ascii() use // So, e-mail address should be validated also on server side after idn_to_ascii() use
//domain_literal = '\\x5b('+dtext+'|'+quoted_pair+')*\\x5d', //domain_literal = '\\x5b('+dtext+'|'+quoted_pair+')*\\x5d',
//sub_domain = '('+atom+'|'+domain_literal+')', //sub_domain = '('+atom+'|'+domain_literal+')',
// allow punycode/unicode top-level domain // allow punycode/unicode top-level domain, allow extended domains (#5588)
domain = '(('+ip_addr+')|(([^@\\x2e]+\\x2e)+([^\\x00-\\x40\\x5b-\\x60\\x7b-\\x7f]{2,}|xn--[a-z0-9]{2,})))', domain = '(('+ip_addr+')|(([^@\\x2e]+\\x2e)+([^\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\x7f]{2,}|xn--[a-z0-9]{2,})))',
// ICANN e-mail test (http://idn.icann.org/E-mail_test) // ICANN e-mail test (http://idn.icann.org/E-mail_test)
icann_domains = [ icann_domains = [
'\\u0645\\u062b\\u0627\\u0644\\x2e\\u0625\\u062e\\u062a\\u0628\\u0627\\u0631', '\\u0645\\u062b\\u0627\\u0644\\x2e\\u0625\\u062e\\u062a\\u0628\\u0627\\u0631',

@ -127,9 +127,11 @@ class rcube_utils
} }
} }
// last domain part // last domain part (allow extended TLD)
$last_part = array_pop($domain_array); $last_part = array_pop($domain_array);
if (strpos($last_part, 'xn--') !== 0 && preg_match('/[^a-zA-Z]/', $last_part)) { if (strpos($last_part, 'xn--') !== 0
&& (preg_match('/[^a-zA-Z0-9]/', $last_part) || preg_match('/^[0-9]+$/', $last_part))
) {
return false; return false;
} }

@ -31,6 +31,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
array('firstname-lastname@domain.com', 'Dash in address field is valid'), array('firstname-lastname@domain.com', 'Dash in address field is valid'),
array('test@xn--e1aaa0cbbbcacac.xn--p1ai', 'IDNA domain'), array('test@xn--e1aaa0cbbbcacac.xn--p1ai', 'IDNA domain'),
array('あいうえお@domain.com', 'Unicode char as address'), array('あいうえお@domain.com', 'Unicode char as address'),
array('test@domain.2legit2quit', 'Extended TLD'),
); );
} }

Loading…
Cancel
Save