Comment 2 for bug 1187464

Revision history for this message
Carlos Vásquez (ClearCorp) (cv.clearcorp) wrote :

Some more thoughts about this.

The best practice here is not wrapping the sender or recipient name in double quotes, the best option is to encode in RFC2822 every time, even if there are only ASCII characters. This is because, the most used standard is that senders or recipients names should not even have spaces.

Try the same example as described by Karsten, but include an UTF8 character in the user name. For example, with "Pan, Pëter". You will see that the problem is gone, same for the recipients.

The easy way to do this, is to allow double quotes in the email_from, email_to, email_cc and email_bcc fields of the build_email method of the ir_mail_server class (openerp/base/ir/ir_mail_server.py). As of now, if any double quotes are passed along to this method (form the mail module for example), the build_email method encodes the name with the quotes included, resulting in an email received form "Pan, Pëter" (the quotes showing in your email client around the name). This is because the quotes get encoded along with the rest because a non ASCII character is found.

So this can be solved by always encoding sender and recipient names, but without encoding the quotes. For this, you must fix the encode_rfc2822_address_header method (the same file) so it can receive the quotes, but without encoding them in the result.

Summarizing, this is the approach that big email providers use (like Gmail). Always encode names in sender and recipients, never use quotes in final messages, if quotes are received, replace them by enconding.

I don't have time right now to change the code myself but I can help to test or share any more thoughts with you if you need me to.

Regards