mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V3.2 to HEAD
15421: ETHREEOH-2511 - Subject field encoding issue with IMAP 15849: Fixes to IMAP UTF-8 handling git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@15851 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -67,7 +67,6 @@ public abstract class AbstractMimeMessage extends MimeMessage
|
||||
/** Used if imapHelper.getDefaultFromAddress is not set */
|
||||
protected static final String DEFAULT_EMAIL_FROM = "alfresco@alfresco.org";
|
||||
protected static final String DEFAULT_EMAIL_TO = DEFAULT_EMAIL_FROM;
|
||||
protected static final String KOI8R_CHARSET = "koi8-r";
|
||||
|
||||
protected static int MAX_RETRIES = 1;
|
||||
|
||||
|
@@ -80,5 +80,6 @@ public interface AlfrescoImapConst
|
||||
public static final String EIGHT_BIT_ENCODING = "8bit";
|
||||
public static final String BASE_64_ENCODING = "base64";
|
||||
public static final String UTF_8 = "UTF-8";
|
||||
public static final String CHARSET_UTF8 = ";charset=utf-8";
|
||||
|
||||
}
|
||||
|
@@ -1,9 +1,5 @@
|
||||
package org.alfresco.repo.imap;
|
||||
|
||||
import static org.alfresco.repo.imap.AlfrescoImapConst.BASE_64_ENCODING;
|
||||
import static org.alfresco.repo.imap.AlfrescoImapConst.CONTENT_TRANSFER_ENCODING;
|
||||
import static org.alfresco.repo.imap.AlfrescoImapConst.UTF_8;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Map;
|
||||
@@ -59,8 +55,8 @@ public class ContentModelMessage extends AbstractMimeMessage
|
||||
prop = (String) properties.get(ContentModel.PROP_TITLE);
|
||||
try
|
||||
{
|
||||
prop = (prop == null) ? messageFileInfo.getName() : prop;
|
||||
prop = MimeUtility.encodeText(prop, KOI8R_CHARSET, null);
|
||||
prop = (prop == null || prop.equals("")) ? messageFileInfo.getName() : prop;
|
||||
prop = MimeUtility.encodeText(prop, AlfrescoImapConst.UTF_8, null);
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
@@ -83,17 +79,18 @@ public class ContentModelMessage extends AbstractMimeMessage
|
||||
// detect an email agent so we use a default template for all messages.
|
||||
// See AlfrescoImapConst to see the possible templates to use.
|
||||
String bodyTxt = getEmailBodyText(EmailBodyType.TEXT_PLAIN);
|
||||
rootMultipart.addBodyPart(getTextBodyPart(bodyTxt, EmailBodyType.TEXT_PLAIN.getSubtype()));
|
||||
rootMultipart.addBodyPart(getTextBodyPart(bodyTxt, EmailBodyType.TEXT_PLAIN.getSubtype(), EmailBodyType.TEXT_PLAIN.getMimeType()));
|
||||
String bodyHtml = getEmailBodyText(EmailBodyType.TEXT_HTML);
|
||||
rootMultipart.addBodyPart(getTextBodyPart(bodyHtml, EmailBodyType.TEXT_HTML.getSubtype()));
|
||||
rootMultipart.addBodyPart(getTextBodyPart(bodyHtml, EmailBodyType.TEXT_HTML.getSubtype(), EmailBodyType.TEXT_HTML.getMimeType()));
|
||||
return rootMultipart;
|
||||
}
|
||||
|
||||
private MimeBodyPart getTextBodyPart(String bodyText, String subtype) throws MessagingException
|
||||
private MimeBodyPart getTextBodyPart(String bodyText, String subtype, String mimeType) throws MessagingException
|
||||
{
|
||||
MimeBodyPart result = new MimeBodyPart();
|
||||
result.setText(bodyText, UTF_8, subtype);
|
||||
result.addHeader(CONTENT_TRANSFER_ENCODING, BASE_64_ENCODING);
|
||||
result.setText(bodyText, AlfrescoImapConst.UTF_8, subtype);
|
||||
result.addHeader(AlfrescoImapConst.CONTENT_TYPE, mimeType + AlfrescoImapConst.CHARSET_UTF8);
|
||||
result.addHeader(AlfrescoImapConst.CONTENT_TRANSFER_ENCODING, AlfrescoImapConst.BASE_64_ENCODING);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user