Issue Details (XML | Word | Printable)

Key: EMAIL-1
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: James Mc Millan
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons Email

[email] setCharset() in Email does not set the charset for the message content

Created: 07/Mar/06 04:43 PM   Updated: 23/Feb/07 12:13 AM
Return to search
Component/s: None
Affects Version/s: 1.0
Fix Version/s: 1.1

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works email-1.patch 2007-02-08 06:39 PM Ben Speakmon 4 kB
Environment:
Operating System: other
Platform: Other
Issue Links:
Reference
 

Bugzilla Id: 38873
Resolution Date: 23/Feb/07 12:13 AM


 Description  « Hide
Hello

More accurately, the charset is not used in buildMimeMessage() as it is not part
of the contentType used when calling message.setContent(). Since
setContentType() updates the charset, I think it makes for setCharset() to
update the contentType?

James



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Michael Stevens added a comment - 06/Aug/06 05:58 AM
As a workaround setContent can be used directly. For example
mail.setCharset(Email.ISO_8859_1); // sets the charset for the subject
mail.setFrom(from);
mail.addTo(user.getEmail());
mail.setSubject(subject);
mail.setContent(mailText, "text/plain; charset=iso-8859-1");

Ben Speakmon added a comment - 21/Dec/06 07:18 PM
This should be fixable without any additional charset code, shouldn't it? Quick glance through the source suggests that it can.

Ben Speakmon added a comment - 10/Jan/07 08:24 PM
Adding link to related issue.

Ben Speakmon added a comment - 08/Feb/07 06:39 PM
Here's a patch to address this. It includes a fix and tests for three scenarios:

1) setContent() with a text content type without any specific charset. If a charset has been previously set, it is automatically applied to the content type. (This fixes the actual issue.)

2) setContent() with a text content type with a specific charset. The content type charset will override any previously set charset and will change the Email's default charset to itself. (This is current behavior.)

3) setContent() with a non-text content type. Any charset already set in the message will be ignored, since we don't want to declare encodings for binary types. Besides, they'll either come with their own encodings or will be left to the underlying platform. (This is also current behavior, but this ensures that the fix for #1 doesn't inadvertently break other types of content.


dion gillard added a comment - 23/Feb/07 12:13 AM
Applied.