This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 2238ea23771c23a1ad278a9bd2d64d9993452094 Author: Benoit Tellier <[email protected]> AuthorDate: Thu Jan 12 10:46:56 2023 +0700 [UPGRADE] Mime4J 0.8.9: use TextBody::getCharset --- .../src/main/scala/org/apache/james/jmap/mail/EmailBodyPart.scala | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailBodyPart.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailBodyPart.scala index 52adbba120..d53005f3f7 100644 --- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailBodyPart.scala +++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailBodyPart.scala @@ -35,6 +35,7 @@ import org.apache.james.jmap.core.Properties import org.apache.james.jmap.mail.EmailBodyPart.{FILENAME_PREFIX, MULTIPART_ALTERNATIVE, TEXT_HTML, TEXT_PLAIN} import org.apache.james.jmap.mail.PartId.PartIdValue import org.apache.james.mailbox.model.{Cid, MessageAttachmentMetadata, MessageId, MessageResult} +import org.apache.james.mime4j.Charsets.DEFAULT_CHARSET import org.apache.james.mime4j.codec.{DecodeMonitor, DecoderUtil} import org.apache.james.mime4j.dom.field.{ContentDispositionField, ContentLanguageField, ContentTypeField, FieldName} import org.apache.james.mime4j.dom.{Entity, Message, Multipart, SingleBody, TextBody => Mime4JTextBody} @@ -275,7 +276,7 @@ case class EmailBodyPart(partId: PartId, def bodyContent: Try[Option[EmailBodyValue]] = entity.getBody match { case textBody: Mime4JTextBody => for { - value <- Try(IOUtils.toString(textBody.getInputStream, charset(Option(textBody.getMimeCharset)))) + value <- Try(IOUtils.toString(textBody.getInputStream, Option(textBody.getCharset).getOrElse(DEFAULT_CHARSET))) } yield { Some(EmailBodyValue(value = value, isEncodingProblem = IsEncodingProblem(false), @@ -292,10 +293,6 @@ case class EmailBodyPart(partId: PartId, case _ => bodyContent } - private def charset(charset: Option[String]): java.nio.charset.Charset = charset - .map(java.nio.charset.Charset.forName) - .getOrElse(org.apache.james.mime4j.Charsets.DEFAULT_CHARSET) - def textBody: List[EmailBodyPart] = selfBody ++ textBodyOfMultipart def htmlBody: List[EmailBodyPart] = selfBody ++ htmlBodyOfMultipart --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
