Fix for auto detecting charset on HTML docs when sending

git-svn-id: svn://10.0.0.236/trunk@43137 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
rhp%netscape.com
1999-08-11 03:28:22 +00:00
parent 2bbda1ed08
commit fee299ef36
2 changed files with 41 additions and 23 deletions

View File

@@ -817,30 +817,33 @@ mime_generate_attachment_headers (const char *type, const char *encoding,
PUSH_STRING ("Content-Type: ");
PUSH_STRING (type);
if (mime_type_needs_charset (type)) {
char charset_label[65]; // Content-Type: charset
if (mime_type_needs_charset (type))
{
char charset_label[65] = ""; // Content-Type: charset
PL_strcpy(charset_label, charset);
/* If the characters are all 7bit, then it's better (and true) to
claim the charset to be US- rather than Latin1. Should we
do this all the time, for all charsets? I'm not sure. But we
should definitely do it for Latin1. */
if (encoding &&
!PL_strcasecmp (encoding, "7bit") &&
!PL_strcasecmp (charset, "iso-8859-1"))
PL_strcpy (charset_label, "us-ascii");
// If charset is JIS and and type is HTML
// then no charset to be specified (apply base64 instead)
// in order to avoid mismatch META_TAG (bug#104255).
if ((PL_strcasecmp(charset, "iso-2022-jp") != 0) ||
(PL_strcasecmp(type, TEXT_HTML) != 0) ||
(PL_strcasecmp(encoding, ENCODING_BASE64) != 0)) {
PUSH_STRING ("; charset=");
PUSH_STRING (charset_label);
}
}
/* If the characters are all 7bit, then it's better (and true) to
claim the charset to be US- rather than Latin1. Should we
do this all the time, for all charsets? I'm not sure. But we
should definitely do it for Latin1. */
if (encoding &&
!PL_strcasecmp (encoding, "7bit") &&
!PL_strcasecmp (charset, "iso-8859-1"))
PL_strcpy (charset_label, "us-ascii");
// If charset is JIS and and type is HTML
// then no charset to be specified (apply base64 instead)
// in order to avoid mismatch META_TAG (bug#104255).
if ( ((PL_strcasecmp(charset, "iso-2022-jp") != 0) ||
(PL_strcasecmp(type, TEXT_HTML) != 0) ||
(PL_strcasecmp(encoding, ENCODING_BASE64) != 0)) &&
(*charset_label))
{
PUSH_STRING ("; charset=");
PUSH_STRING (charset_label);
}
}
if (x_mac_type && *x_mac_type) {
PUSH_STRING ("; x-mac-type=\"");

View File

@@ -1494,6 +1494,21 @@ nsMsgComposeAndSend::AddCompFieldLocalAttachments()
if ((!m_attachments[newLoc].m_type) || (!*m_attachments[newLoc].m_type))
m_attachments[newLoc].m_type = PL_strdup(APPLICATION_OCTET_STREAM);
// For local files, if they are HTML docs and we don't have a charset, we should
// sniff the file and see if we can figure it out.
if ( (m_attachments[newLoc].m_type) && (*m_attachments[newLoc].m_type) )
{
if (PL_strcasecmp(m_attachments[newLoc].m_type, TEXT_HTML) == 0)
{
char *tmpCharset = (char *)nsMsgI18NParseMetaCharset(m_attachments[newLoc].mFileSpec);
if (tmpCharset[0] != '\0')
{
PR_FREEIF(m_attachments[newLoc].m_charset);
m_attachments[newLoc].m_charset = PL_strdup(tmpCharset);
}
}
}
++newLoc;
}