Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't send from domains with special characters + identity name encoding wrong #8357

Closed
codegain opened this issue Dec 9, 2021 · 2 comments

Comments

@codegain
Copy link
Contributor

codegain commented Dec 9, 2021

Hi,

as stated in #8106, the fix resulted in sending from domains with special characters no longer working.

The previous code in 1.4.11 was:

// ... if there is no identity record, this might be a custom from
else if (($from_string = $this->email_input_format($from))
    && preg_match('/(\S+@\S+)/', $from_string, $m)
) {
    $from = trim($m[1], '<>');
}
// ... otherwise it's empty or invalid
else {
    $from = null;
}

which included $this->email_input_format($from) and automatically converted something like myuser@mydomäin.com to myuser@xn--mydomin-9wa.com. This is no longer the case in the new code (1.4.12):

else {
    // ... if there is no identity record, this might be a custom from
    $from_addresses = rcube_mime::decode_address_list($from);

    if (count($from_addresses) == 1) {
        $from        = $from_addresses[1]['mailto'];
        $from_string = $from_addresses[1]['string'];
    }
    // ... otherwise it's empty or invalid
    else {
        $from = null;
    }
}

I could fix this by changing this line and include the call to $this->email_input_format:

    // ... if there is no identity record, this might be a custom from
    $from_addresses = rcube_mime::decode_address_list($this->email_input_format($from));

And another issue popped up with the new code: If using a display name in the identity with Umlauts like My näme the email can be sent, but the recipient recieves it as My näme.
You can test this like:

$from = 'My näme <my.name@my.domain.tld>';
var_dump($from);
// ... if there is no identity record, this might be a custom from
$from_addresses = rcube_mime::decode_address_list($from);
var_dump($from_addresses);
die();

which results to:

string(32) "My näme <my.name@my.domain.tld>"
array(1) {
  [1]=>
  array(3) {
    ["name"]=>
    string(10) "My näme"
    ["mailto"]=>
    string(21) "my.name@my.domain.tld"
    ["string"]=>
    string(34) "My näme <my.name@my.domain.tld>"
  }
}

Currently using roundcube 1.4.12 on PHP 7.4.

@codegain
Copy link
Contributor Author

codegain commented Dec 9, 2021

This seems to be working to fix all above problems currently:

$from_addresses = rcube_mime::decode_address_list($this->email_input_format($from), null, false);

@alecpl
Copy link
Member

alecpl commented Dec 12, 2021

Fixed.

@alecpl alecpl closed this as completed Dec 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants