Changed csid to charset name for MIME header decoding.

This commit is contained in:
nhotta%netscape.com 1999-02-11 00:43:20 +00:00
parent ec576a4e21
commit 0085ce15fd
2 changed files with 21 additions and 9 deletions

View File

@ -83,6 +83,8 @@ extern int MK_MSG_SHOW_ALL_RECIPIENTS;
extern int MK_MSG_SHOW_SHORT_RECIPIENTS;
#endif /* RICHIE */
extern char *MIME_DecodeMimePartIIStr(const char *header, char *charset);
char *
MIME_StripContinuations(char *original);
@ -752,6 +754,8 @@ MimeHeaders_default_addbook_link_generator (const char *dest, void *closure,
char* mouseOverText = NULL;
int j;
int num = MSG_ParseRFC822Addresses(dest, &names, &addresses);
char charsetName[128];
charsetName[0] = 0;
PR_ASSERT(num >= 1);
for (j=0 ; j<num ; j++) {
if (addr) {
@ -772,13 +776,14 @@ MimeHeaders_default_addbook_link_generator (const char *dest, void *closure,
MSG_UnquotePhraseOrAddr (name, &unquotedName);
winCharSetID = INTL_DefaultWinCharSetID(0);
converted = INTL_DecodeMimePartIIStr((const char *) unquotedName, winCharSetID, PR_FALSE);
converted = MIME_DecodeMimePartIIStr((const char *) unquotedName, charsetName);
if (converted && (converted != unquotedName)) {
char charsetName[128];
charsetName[0] = 0;
PR_FREEIF(unquotedName);
unquotedName = converted;
INTL_CharSetIDToName(winCharSetID, charsetName);
//TODO: naoki - After the decode, we may need to do a charset conversion.
// If this is to handed to a widget then probably convert to unicode.
// If this is put inside an HTML then convet to the content type charset of the HTML.
// INTL_CharSetIDToName(winCharSetID, charsetName);
if (charsetName[0]) {
charset = PR_smprintf(";cs=%s", charsetName);
} else {
@ -2751,7 +2756,9 @@ mime_decode_filename(char *name)
char *s = name, *d = name;
char *cvt, *returnVal = NULL;
PRInt16 mail_csid = CS_DEFAULT, win_csid = CS_DEFAULT;
char charsetName[128];
charsetName[0] = 0;
while (*s)
{
/* Remove backslashes when they are used to escape special characters. */
@ -2776,12 +2783,13 @@ mime_decode_filename(char *name)
if (d) *d = '?';
win_csid = INTL_DocToWinCharSetID(mail_csid);
cvt = INTL_DecodeMimePartIIStr(returnVal, win_csid, PR_FALSE);
cvt = MIME_DecodeMimePartIIStr(returnVal, charsetName);
if (cvt && cvt != returnVal)
returnVal = cvt;
}
//TODO: naoki - We now have a charset name returned and no need for the hack.
// Check if charset is JIS then apply the conversion.
/* Seriously ugly hack. If the first three characters of the filename
are <ESC>$B, then we know the filename is in JIS and should be
converted to either SJIS or EUC-JP. */

View File

@ -88,6 +88,8 @@ extern NET_StreamClass *msg_MakeRebufferingStream (NET_StreamClass *next,
MWContext *context);
extern char *MIME_DecodeMimePartIIStr(const char *header, char *charset);
/* Interface between netlib and the top-level message/rfc822 parser:
MIME_MessageConverter()
*/
@ -233,6 +235,9 @@ mime_convert_rfc1522 (const char *input_line, PRInt32 input_length,
struct mime_stream_data *msd = (struct mime_stream_data *) stream_closure;
char *converted;
char *line;
char charset[128];
charset[0] = '\0';
if (input_line[input_length] == 0) /* oh good, it's null-terminated */
line = (char *) input_line;
@ -244,8 +249,7 @@ mime_convert_rfc1522 (const char *input_line, PRInt32 input_length,
line[input_length] = 0;
}
converted = IntlDecodeMimePartIIStr(line,
INTL_DocToWinCharSetID(INTL_DefaultDocCharSetID(msd->context)), PR_FALSE);
converted = MIME_DecodeMimePartIIStr(line, charset);
if (line != input_line)
PR_Free(line);