You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mime4j-dev@james.apache.org by Wim Jongman <wi...@gmail.com> on 2009/08/16 15:00:27 UTC
DecoderUtil question.
Hi,
I came across this line in a message:
utf "=?utf-8?Q?Re:=20How=20to=20place=20a=20view=20at=20the=20bottom?=
=?utf-8?Q?=20with=20a=20100%=20width?="
System.out.println(DecoderUtil.decodeEncodedWords(utf));
gives:
Re: How to place a view at the bottom =?utf-8?Q?=20with=20a=20100%=20width?=
but should give:
Re: How to place a view at the bottom with a 100% width
Is there something i have missed?
Best regards,
Wim
Re: DecoderUtil question.
Posted by Markus Wiederkehr <ma...@gmail.com>.
On Sun, Aug 16, 2009 at 3:00 PM, Wim Jongman<wi...@gmail.com> wrote:
> Hi,
> I came across this line in a message:
>
> utf "=?utf-8?Q?Re:=20How=20to=20place=20a=20view=20at=20the=20bottom?=
> =?utf-8?Q?=20with=20a=20100%=20width?="
> System.out.println(DecoderUtil.decodeEncodedWords(utf));
>
> gives:
>
> Re: How to place a view at the bottom =?utf-8?Q?=20with=20a=20100%=20width?=
>
> but should give:
>
> Re: How to place a view at the bottom with a 100% width
Hi Wim,
I think you've found a bug in Mime4j..
DecoderUtil assumes that an encoded word starts with =? and ends with
the first occurrence of ?= following the =?.
In your case it falsely identifies =?utf-8?Q?= as the encoded word and
ignores the remainder (20with=20...). It then fails to decode
=?utf-8?Q?= and returns the string as is..
RFC 2047 section 5 states that <quote>for a "Q" 'encoded-word', any
"=" character that appears in the 'encoded-text' portion will be
followed by two hexadecimal characters.</quote>
Thanks,
Markus
> Is there something i have missed?
>
> Best regards,
>
> Wim
Re: DecoderUtil question.
Posted by Wim Jongman <wi...@gmail.com>.
Hi,
Confirmed that the latest from repository works for my example.
I wish you and your dear ones to live long, happy and in good health.
Best regards,
Wim
On Sun, Aug 16, 2009 at 3:00 PM, Wim Jongman <wi...@gmail.com> wrote:
> Hi,
> I came across this line in a message:
>
> utf "=?utf-8?Q?Re:=20How=20to=20place=20a=20view=20at=20the=20bottom?=
> =?utf-8?Q?=20with=20a=20100%=20width?="
> System.out.println(DecoderUtil.decodeEncodedWords(utf));
>
> gives:
>
> Re: How to place a view at the bottom
> =?utf-8?Q?=20with=20a=20100%=20width?=
>
> but should give:
>
> Re: How to place a view at the bottom with a 100% width
>
> Is there something i have missed?
>
> Best regards,
>
> Wim
>
>
Re: DecoderUtil question.
Posted by Norman Maurer <no...@apache.org>.
+1,
Can you please open a bugreport in jira ? (Just to keep track).
Thx,
Norman
2009/8/16 Markus Wiederkehr <ma...@gmail.com>:
> On Sun, Aug 16, 2009 at 3:00 PM, Wim Jongman<wi...@gmail.com> wrote:
>> Hi,
>> I came across this line in a message:
>>
>> utf "=?utf-8?Q?Re:=20How=20to=20place=20a=20view=20at=20the=20bottom?=
>> =?utf-8?Q?=20with=20a=20100%=20width?="
>> System.out.println(DecoderUtil.decodeEncodedWords(utf));
>>
>> gives:
>>
>> Re: How to place a view at the bottom =?utf-8?Q?=20with=20a=20100%=20width?=
>>
>> but should give:
>>
>> Re: How to place a view at the bottom with a 100% width
>
> FWIW JavaMail's MimeUtility.decodeText() gives the correct result.
>
> I think the strategy should be to parse charset and encoding, then
> decode the encoded-text as far as possible (using either B or Q
> encoding), then expect the trailing ?=.
>
> Markus
>
>>
>> Is there something i have missed?
>>
>> Best regards,
>>
>> Wim
>
Re: DecoderUtil question.
Posted by Markus Wiederkehr <ma...@gmail.com>.
On Sun, Aug 16, 2009 at 3:00 PM, Wim Jongman<wi...@gmail.com> wrote:
> Hi,
> I came across this line in a message:
>
> utf "=?utf-8?Q?Re:=20How=20to=20place=20a=20view=20at=20the=20bottom?=
> =?utf-8?Q?=20with=20a=20100%=20width?="
> System.out.println(DecoderUtil.decodeEncodedWords(utf));
>
> gives:
>
> Re: How to place a view at the bottom =?utf-8?Q?=20with=20a=20100%=20width?=
>
> but should give:
>
> Re: How to place a view at the bottom with a 100% width
FWIW JavaMail's MimeUtility.decodeText() gives the correct result.
I think the strategy should be to parse charset and encoding, then
decode the encoded-text as far as possible (using either B or Q
encoding), then expect the trailing ?=.
Markus
>
> Is there something i have missed?
>
> Best regards,
>
> Wim