-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
java.io.UnsupportedEncodingException: en_US.iso885915 if charset is "en_US.iso885915" #107
Comments
It should work but, there are some alternatives to consider:
It is something to consider. When I check the jakarta.mail.internet.MimeUtility we already have mappings that include a locale. We might have to include other locale prefixes. Do you know what mailer generated this content-type header? |
In my customer case it looks like they were using Outlook. But the problem can be recreated with any mail server and if we set 'Content-Type: text/html; charset="en_US.iso885915" header in the outgoing email. |
Committed to 2.0.3 as: I added the mapping. It looks like there are other variants of this. I think if we need to revisit this for more mappings then I think we need to look at modifying the MimeUtility to perform a table lookup then charset lookup and if that fails substring the charset so there is no locale and try again. However, there could be issues with doing that too. |
We embed Angus mail Jars in IBM App Connect Enterprise in order to provide email functionalities.
When an attempt is made to get the content of the email using 'getContent()' API, it is failing with following exception for one particular scenario for our clients.
'java.io.UnsupportedEncodingException: en_US.iso885915 at sun.nio.cs.StreamDecoder.forInputStreamReader(StreamDecoder.java:104) at java.io.InputStreamReader.(InputStreamReader.java:121) at com.sun.mail.handlers.text_plain.getContent(text_plain.java:59) at jakarta.activation.DataSourceDataContentHandler.getContent(DataHandler.java:768) at jakarta.activation.DataHandler.getContent(DataHandler.java:514) at jakarta.mail.internet.MimeBodyPart.getContent(MimeBodyPart.java:659)
Here the email is having 'Content-Type: text/html; charset="en_US.iso885915" header. 'en_US.iso885915' is not a valid charSet in java and is the reason for the above exception.
On looking at the source code, it looks like the jar file is having javamail.charset.map file to map the charSets. If we add a mapping for en_US.iso885915 the error can be avoided ie add 'en_US.iso885915 ISO-8859-15' to the jakarta.mail-2.0.2.jar/META-INF/javamail.charset.map file.
Could you please advise whether this is a valid change to have and avoid the error. If so, can this change be included in future releases of jakarta-mail jar.
Following are the version of jars in use :
jakarta.mail-2.0.2.jar
((The Angus Mail implementation jar file, including the Jakarta Mail API, SMTP, IMAP, and POP3 protocol providers and java.util.logging handler)
angus-activation-2.0.1.jar
jakarta.activation-api-2.1.2.jar
To Reproduce
Create a mail with 'Content-Type: text/html; charset="en_US.iso885915"
Invoke getContent() API on the email and it fails.
Expected behavior
To process the email even if it uses charset="en_US.iso885915"
Desktop (please complete the following information):
Mail server:
The text was updated successfully, but these errors were encountered: