xoot123_at_yahoo.it wrote on 06/27/2013 05:55 AM:
> Hello,
> when I receive an email whose subject has accented letters (i.e. "ripròva")
> the first reply shows the subject "Re: ripròva", but the next reply to the
> latter shows "Re: Re: ripròva", adding another prefix.
> This is because in the actual email text the subject header is like "Subject:
> =?UTF-8?Q?Re:_ripr=C3=B2va?=", so I guess that the existing "Re: " isn't
> detected by Javamail and another one is prefixed.
>
> When the subject is shown in the application it looks fine, so the utf-8
> encoding is properly decoded.
>
> Is this something that can be fixed with a JavaMail parameter? Should I
> manipulate somehow the subject before invoking reply()?
The code currently has this comment:
/*
* Have to manipulate the raw Subject header so that we don't lose
* any encoding information. This is safe because "Re:" isn't
* internationalized and (generally) isn't encoded. If the entire
* Subject header is encoded, prefixing it with "Re: " still leaves
* a valid and correct encoded header.
*/
There's really no need to encode the word "Re:", so applications that do so are
just being lazy. I suppose JavaMail could decode the header first, and then
prepend an unencoded "Re:" to the encoded header if necessary.
As a workaround you can use getSubject() on the reply message and strip off
multiple instances of "Re:" and use setSubject() on the result. That will work
fine as long as all the encoding information is correct in the original message
and you're willing to always use utf-8 for the reply message.