diff options
| author | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2011-02-03 13:58:07 +0000 |
|---|---|---|
| committer | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2011-02-03 13:58:07 +0000 |
| commit | 087ed09fd1ff749848acc82505db7e80145fa834 (patch) | |
| tree | ec1632d05faa9df6ab4fb7f3326cb8259e613fda /roundcubemail/program/include/main.inc | |
| parent | 6e3ab8ae0acca60e7e8c6d09fb9509ad4103c0ee (diff) | |
- Fix IDNA support when IDN/INTL modules are in use (#1487742)
git-svn-id: https://svn.roundcube.net/trunk@4484 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program/include/main.inc')
| -rw-r--r-- | roundcubemail/program/include/main.inc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/roundcubemail/program/include/main.inc b/roundcubemail/program/include/main.inc index 7f4945692..697b3ff21 100644 --- a/roundcubemail/program/include/main.inc +++ b/roundcubemail/program/include/main.inc @@ -1891,6 +1891,39 @@ function check_email($email, $dns_check=true) return false; } +/* + * Idn_to_ascii wrapper. + * Intl/Idn modules version of this function doesn't work with e-mail address + */ +function rcube_idn_to_ascii($str) +{ + return rcube_idn_convert($str, true); +} + +/* + * Idn_to_ascii wrapper. + * Intl/Idn modules version of this function doesn't work with e-mail address + */ +function rcube_idn_to_utf8($str) +{ + return rcube_idn_convert($str, false); +} + +function rcube_idn_convert($input, $is_utf=false) +{ + if ($at = strpos($input, '@')) { + $user = substr($input, 0, $at); + $domain = substr($input, $at+1); + } + else { + $domain = $input; + } + + $domain = $is_utf ? idn_to_ascii($domain) : idn_to_utf8($domain); + + return $at ? $user . '@' . $domain : $domain; +} + /** * Helper class to turn relative urls into absolute ones |
