#1487742 closed Bugs (fixed)
IDNA support problem (ICANN e-mail test)
| Reported by: | arser | Owned by: | |
|---|---|---|---|
| Priority: | 5 | Milestone: | 0.5.1 |
| Component: | Core functionality | Version: | 0.5 |
| Severity: | normal | Keywords: | idn idna |
| Cc: |
Description
When I tried to send to "mailtest@пример.испытание" (ICANN e-mail test), I got an error "Please enter at least one recipient". Same error I got when trying to send to punicode notation "mailtest@xn--e1afmkfd.xn--80akhbyknj4f".
However, when I tried to write the address "mailtest@xn--e1afmkfd.xn--80akhbyknj4f" in the Copy field, the letter sent successfully.
Although when I tried to write the address "mailtest@пример.испытание" in the Copy field I got an error "Invalid e-mail address: xn--mailtest@-o0h6a0cxbod.xn--80akhbyknj4f".
In the last error address incorrectly encoded. When I view in roundcube sent letter, address "mailtest@xn--e1afmkfd.xn--80akhbyknj4f" also incorrectly decoded to "mailtest@xn--e1afmkfd.испытание".
I think, "username@" is perceived as part of the domain name, resulting in a domain name is not correctly encoded/decoded, as well as username is corrupted.
Change History (7)
comment:1 Changed 2 years ago by alec
- Milestone changed from later to 0.5.1
comment:2 Changed 2 years ago by charly
comment:3 Changed 2 years ago by charly
may be a function should help on this, but i don't know were to declare it.
A small function like this can handle a full email and convert it to punycode:
function email_idna_to_ascii($email)
{
$at=strpos($email,'@');
$user=substr($email,0,$at);
$domain=idna_to_ascii(substr($email,$at));
$new_email = $user . '@' . $domain;
return $new_email;
}
i know you will rework this on a better function, but you can get the idea on this
comment:4 Changed 2 years ago by alec
Right. It looks that we can't pass e-mail address to Intl/Idn?'s functions. PEAR::Net_IDNA2 supports this. We need to use wrapper functions.
comment:5 Changed 2 years ago by alec
- Summary changed from IDNA support problem to IDNA support problem (ICANN e-mail test)
idn_* functions issue is fixed in [e8d5bdc8] and r4485/svn. We still need a fix for ICANN test e-mails.
comment:6 Changed 2 years ago by alec
- Resolution set to fixed
- Status changed from new to closed
Fixed in [e18d992e] and [47f55c0d].
comment:7 Changed 2 years ago by arser
Everything seems to work well now. Thank you!

i found some places on which we are mistaking the use of idna_to_ascii
if you see http://www.php.net/manual/es/function.idn-to-ascii.php you will see that the function translates a domain to punycode, but only the domain and not the entire e-mail address.
this is a small fix i was working on, on one of the places i found idna_to_ascii to be used in the wrong way:
Index: trunk/roundcubemail/program/include/rcmail.php =================================================================== --- trunk/roundcubemail/program/include/rcmail.php (revisión: 4482) +++ trunk/roundcubemail/program/include/rcmail.php (copia de trabajo) @@ -703,8 +703,10 @@ if (strpos($username, '@')) { // lowercase domain name list($local, $domain) = explode('@', $username); - $username = $local . '@' . mb_strtolower($domain); - $username = idn_to_ascii($username); + +// idn_to_ascii process only the domain, not the user@ part of the email: + $username = $local . '@' . idn_to_ascii( mb_strtolower($domain) ); +// wrong: $username = idn_to_ascii($username); }This is the list of files that need to be changed and the lines i found using 'grep':
trunk/roundcubemail/program/include/rcmail.php $username = idn_to_ascii($username); trunk/roundcubemail/program/include/rcube_smtp.php $smtp_user = idn_to_ascii($smtp_user); trunk/roundcubemail/installer/test.php $from = idn_to_ascii(trim($_POST['_from'])); $to = idn_to_ascii(trim($_POST['_to'])); $imap_host = idn_to_ascii($imap_host); $imap_user = idn_to_ascii($_POST['_user']); trunk/roundcubemail/plugins/squirrelmail_usercopy/squirrelmail_usercopy.php if (check_email(idn_to_ascii($rec['email']))) { trunk/roundcubemail/plugins/virtuser_query/virtuser_query.php 'email' => idn_to_ascii($sql_arr[0]), 'reply-to' => idn_to_ascii($sql_arr[3]), 'bcc' => idn_to_ascii($sql_arr[4]), trunk/roundcubemail/plugins/virtuser_file/virtuser_file.php $result[] = idn_to_ascii(trim(str_replace('\\@', '@', $arr[0]))); trunk/roundcubemail/plugins/new_user_dialog/new_user_dialog.php $save_data['email'] = idn_to_ascii($save_data['email']); trunk/roundcubemail/plugins/new_user_identity/new_user_identity.php $args['user_email'] = idn_to_ascii($results->records[0]['email']); trunk/plugins/squirrelmail_usercopy/squirrelmail_usercopy.php if (check_email(idn_to_ascii($rec['email']))) { trunk/plugins/virtuser_query/virtuser_query.php 'email' => idn_to_ascii($sql_arr[0]), 'reply-to' => idn_to_ascii($sql_arr[3]), 'bcc' => idn_to_ascii($sql_arr[4]), trunk/plugins/virtuser_file/virtuser_file.php $result[] = idn_to_ascii(trim(str_replace('\\@', '@', $arr[0]))); trunk/plugins/new_user_dialog/new_user_dialog.php $save_data['email'] = idn_to_ascii($save_data['email']); trunk/plugins/new_user_identity/new_user_identity.php $args['user_email'] = idn_to_ascii($results->records[0]['email']);i think this should help you on fixing this bug
regards