You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by tide08 <sa...@yahoo.com> on 2010/06/02 02:36:31 UTC
Re: Camel-Mail: Subject cannot handle unicode chars?
Sorry, for late follow up on this.
As I mentioned before, I have the fix and I can submit the patch. But I am
not sure if encoding is platform specific and will cause issues or/and make
unit test difficult.
For ex: Mail with below subject, shows up in mail envelope like -
Subject = My Camel \u2122
With Fix:
Subject: =?MacRoman?Q?My_Camel_=A8_=AA?=
Is the prepended chars platform specific? I don't have much knowledge on
this but can this break on other platforms?
Let me know and I can submit patch to JIRA.
Thanks!
willem.jiang wrote:
>
> Hi,
>
> In camel you can get the Charset information from exchange, I just
> created a JIRA[1] for it, it should be easy to fix.
>
> [1]https://issues.apache.org/activemq/browse/CAMEL-2763
>
> Willem
>
>
> tide08 wrote:
>> It looks like camel-mail cannot handle unicode chars in subject header? I
>> have something like below and subject does not appear correctly in mail
>> client -
>>
>> @Test
>> public void testMailSubjectWithUnicode() throws Exception {
>> Mailbox.clearAll();
>>
>> String body = "Hello Camel Riders!";
>> String subject = "My Camel \u2122";
>>
>> MockEndpoint mock = getMockEndpoint("mock:result");
>> mock.expectedMessageCount(1);
>> //mock.expectedHeaderReceived("subject", "My_Camel_=AA");
>> mock.expectedBodiesReceived(body);
>>
>> template.sendBodyAndHeader("direct:a", body, "subject", subject);
>>
>> mock.assertIsSatisfied();
>>
>> assertFalse("Should not have attachements",
>> mock.getExchanges().get(0).getIn().hasAttachments());
>> }
>>
>> I tried looking into fix but I am exactly not sure if I have the right
>> fix.
>> It looks like in MailBinding class subject is not added using correct
>> method
>> -
>>
>> mimeMessage.setHeader(headerName, asString(exchange, headerValue));
>>
>> but should instead be?
>>
>> mimeMessage.setSubject(asString(exchange, headerValue));
>>
>> Looking at JavaDoc and source it looks like setSubject() method will
>> actually find right encoder and do the encoding for subject. I made
>> changes
>> to mailBinding and it indeed fixed it but looks like it uses platform
>> specific encoding so was confused if that is right approach, any ideas?
>>
>> Also, platform specific encoding may make unit testing difficult?
>>
>>
>> Thanks!
>>
>>
>>
>>
>>
>>
>
>
>
--
View this message in context: http://old.nabble.com/Camel-Mail%3A-Subject-cannot-handle-unicode-chars--tp28700124p28748954.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Camel-Mail: Subject cannot handle unicode chars?
Posted by Willem Jiang <wi...@gmail.com>.
Hi,
Here is the unit test[1] which shows you that how to specify the charset
for encoding, maybe you can take a look at it.
BTW, which version of Camel are you using?
The default Charset of Camel is changed to be UTF-8.
[1]http://svn.apache.org/viewvc?rev=949109&view=rev
Willem
tide08 wrote:
> Sorry, for late follow up on this.
>
> As I mentioned before, I have the fix and I can submit the patch. But I am
> not sure if encoding is platform specific and will cause issues or/and make
> unit test difficult.
>
> For ex: Mail with below subject, shows up in mail envelope like -
>
> Subject = My Camel \u2122
>
> With Fix:
>
> Subject: =?MacRoman?Q?My_Camel_=A8_=AA?=
>
> Is the prepended chars platform specific? I don't have much knowledge on
> this but can this break on other platforms?
>
> Let me know and I can submit patch to JIRA.
>
> Thanks!
>
>
> willem.jiang wrote:
>> Hi,
>>
>> In camel you can get the Charset information from exchange, I just
>> created a JIRA[1] for it, it should be easy to fix.
>>
>> [1]https://issues.apache.org/activemq/browse/CAMEL-2763
>>
>> Willem
>>
>>
>> tide08 wrote:
>>> It looks like camel-mail cannot handle unicode chars in subject header? I
>>> have something like below and subject does not appear correctly in mail
>>> client -
>>>
>>> @Test
>>> public void testMailSubjectWithUnicode() throws Exception {
>>> Mailbox.clearAll();
>>>
>>> String body = "Hello Camel Riders!";
>>> String subject = "My Camel \u2122";
>>>
>>> MockEndpoint mock = getMockEndpoint("mock:result");
>>> mock.expectedMessageCount(1);
>>> //mock.expectedHeaderReceived("subject", "My_Camel_=AA");
>>> mock.expectedBodiesReceived(body);
>>>
>>> template.sendBodyAndHeader("direct:a", body, "subject", subject);
>>>
>>> mock.assertIsSatisfied();
>>>
>>> assertFalse("Should not have attachements",
>>> mock.getExchanges().get(0).getIn().hasAttachments());
>>> }
>>>
>>> I tried looking into fix but I am exactly not sure if I have the right
>>> fix.
>>> It looks like in MailBinding class subject is not added using correct
>>> method
>>> -
>>>
>>> mimeMessage.setHeader(headerName, asString(exchange, headerValue));
>>>
>>> but should instead be?
>>>
>>> mimeMessage.setSubject(asString(exchange, headerValue));
>>>
>>> Looking at JavaDoc and source it looks like setSubject() method will
>>> actually find right encoder and do the encoding for subject. I made
>>> changes
>>> to mailBinding and it indeed fixed it but looks like it uses platform
>>> specific encoding so was confused if that is right approach, any ideas?
>>>
>>> Also, platform specific encoding may make unit testing difficult?
>>>
>>>
>>> Thanks!
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>