fixed bug 21688 -- [Dogfood] Headers are all collapsed into 1 line when forwarding certain types of msgs; conditionally strip out line continuation; r=rhp

This commit is contained in:
jefft%netscape.com 2000-01-05 15:46:06 +00:00
Родитель f5a6e0ef07
Коммит 398cac9ed2
10 изменённых файлов: 39 добавлений и 31 удалений

Просмотреть файл

@ -229,13 +229,13 @@ char * nsMsgI18NEncodeMimePartIIStr(const char *header, const char *charset, PRB
}
// MIME decoder
nsresult nsMsgI18NDecodeMimePartIIStr(const nsString& header, nsString& charset, nsString& decodedString)
nsresult nsMsgI18NDecodeMimePartIIStr(const nsString& header, nsString& charset, nsString& decodedString, PRBool eatContinuations)
{
nsIMimeConverter *converter;
nsresult res = nsComponentManager::CreateInstance(kCMimeConverterCID, nsnull,
nsCOMTypeInfo<nsIMimeConverter>::GetIID(), (void **)&converter);
if (NS_SUCCEEDED(res) && nsnull != converter) {
res = converter->DecodeMimePartIIStr(header, charset, decodedString);
res = converter->DecodeMimePartIIStr(header, charset, decodedString, eatContinuations);
NS_RELEASE(converter);
}
return res;

Просмотреть файл

@ -46,7 +46,7 @@ NS_MSG_BASE nsresult ConvertToUnicode(const nsString& aCharset,
const char* inCString,
nsString& outString);
NS_MSG_BASE nsresult nsMsgI18NDecodeMimePartIIStr(const nsString& header, nsString& charset, nsString& decodedString);
NS_MSG_BASE nsresult nsMsgI18NDecodeMimePartIIStr(const nsString& header, nsString& charset, nsString& decodedString, PRBool eatContinuations=PR_TRUE);
NS_MSG_BASE const char *nsMsgI18NParseMetaCharset(nsFileSpec* fileSpec);

Просмотреть файл

@ -56,12 +56,14 @@ public:
// Decode routine
NS_IMETHOD DecodeMimePartIIStr(const char *header,
char *charset,
char **decodedString) = 0;
char **decodedString,
PRBool eatContinuations = PR_TRUE) = 0;
// Decode routine (also converts output to unicode)
NS_IMETHOD DecodeMimePartIIStr(const nsString& header,
nsString& charset,
nsString& decodedString) = 0;
nsString& decodedString,
PRBool eatContinuations = PR_TRUE) = 0;
// Encode routine
NS_IMETHOD EncodeMimePartIIStr(const char *header,

Просмотреть файл

@ -1510,7 +1510,8 @@ PRInt32 MIME_ConvertCharset(const PRBool autoDetection, const char* from_charset
return res;
}
extern "C" char *MIME_DecodeMimePartIIStr(const char *header, char *charset)
extern "C" char *MIME_DecodeMimePartIIStr(const char *header, char *charset,
PRBool eatContinuations)
{
char *result = nsnull;
@ -1519,7 +1520,9 @@ extern "C" char *MIME_DecodeMimePartIIStr(const char *header, char *charset)
// If no MIME encoded then do nothing otherwise decode the input.
if (*header != '\0' && intlmime_is_mime_part2_header(header)) {
result = MIME_StripContinuations(intl_decode_mime_part2_str(header, charset));
result = intl_decode_mime_part2_str(header, charset);
if (eatContinuations)
result = MIME_StripContinuations(result);
}
else if (*charset == '\0') {
// no charset name is specified then assume it's us-ascii and dup the input

Просмотреть файл

@ -89,7 +89,8 @@ extern "C" {
* Caller should allocate at least 65 bytes (kMAX_CSNAME + 1) for a charset name.
* @return Decoded buffer (in C string) or return NULL if the header is not MIME encoded.
*/
extern "C" char *MIME_DecodeMimePartIIStr(const char *header, char *charset);
extern "C" char *MIME_DecodeMimePartIIStr(const char *header, char *charset,
PRBool eatContinuations);
/**
* Encode an input string into RFC 2047 form.

Просмотреть файл

@ -66,7 +66,8 @@ int mime_decompose_file_output_fn ( char *buf, PRInt32 size, voi
int mime_decompose_file_close_fn ( void *stream_closure );
extern int MimeHeaders_build_heads_list(MimeHeaders *hdrs);
static nsString& mime_decode_string(const char* str /*, PRBool toHtml*/);
static nsString& mime_decode_string(const char* str ,
PRBool eatContinuations = PR_TRUE);
// CID's
static NS_DEFINE_CID(kCMsgComposeServiceCID, NS_MSGCOMPOSESERVICE_CID);
@ -235,21 +236,13 @@ mime_dump_attachments ( attachmentList );
return rv;
}
static nsString& mime_decode_string(const char* str /*,
PRBool toHtml = PR_FALSE */)
static nsString& mime_decode_string(const char* str,
PRBool eatContinuations)
{
static nsString decodedString;
nsString encodedCharset;
nsMsgI18NDecodeMimePartIIStr(nsString(str), encodedCharset,
decodedString);
#if 0
if (toHtml)
{
nsString htmlString;
nsMsgI18NConvertToEntity(decodedString, &htmlString);
decodedString = htmlString;
}
#endif
decodedString, eatContinuations);
return decodedString;
}
@ -1290,7 +1283,7 @@ mime_parse_stream_complete (nsMIMESession *stream)
}
// setting the charset while we were creating the composition fields
// fields->SetCharacterSet(nsString("UTF-8").GetUnicode());
fields->SetBody(mime_decode_string(body).GetUnicode());
fields->SetBody(mime_decode_string(body, PR_FALSE).GetUnicode());
PR_FREEIF(body);
} // end if (messageBody)

Просмотреть файл

@ -44,7 +44,9 @@
#include "mimemoz2.h"
// Forward declares...
extern "C" char *MIME_DecodeMimePartIIStr(const char *header, char *charset);
extern "C" char *MIME_DecodeMimePartIIStr(const char *header,
char *charset,
PRBool eatContinuations);
extern "C" char *MIME_StripContinuations(char *original);
int MimeHeaders_build_heads_list(MimeHeaders *hdrs);
@ -872,7 +874,7 @@ mime_decode_filename(char *name)
if (d) *d = '?';
win_csid = INTL_DocToWinCharSetID(mail_csid);
cvt = MIME_DecodeMimePartIIStr(returnVal, charsetName);
cvt = MIME_DecodeMimePartIIStr(returnVal, charsetName, PR_TRUE);
// rhp - trying to fix header conversion bug
//

Просмотреть файл

@ -78,7 +78,9 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
// Text Scanning...
static NS_DEFINE_CID(kTXTToHTMLConvCID, MOZITXTTOHTMLCONV_CID);
extern "C" char *MIME_DecodeMimePartIIStr(const char *header, char *charset);
extern "C" char *MIME_DecodeMimePartIIStr(const char *header,
char *charset,
PRBool eatContinuations);
static MimeHeadersState MIME_HeaderType;
static PRBool MIME_NoInlineAttachments;
@ -520,7 +522,7 @@ mime_convert_rfc1522 (const char *input_line, PRInt32 input_length,
line[input_length] = 0;
}
converted = MIME_DecodeMimePartIIStr(line, charset);
converted = MIME_DecodeMimePartIIStr(line, charset, PR_TRUE);
if (line != input_line)
PR_Free(line);

Просмотреть файл

@ -51,7 +51,8 @@ nsMimeConverter::~nsMimeConverter()
nsresult
nsMimeConverter::DecodeMimePartIIStr(const nsString& header,
nsString& charset,
nsString& decodedString)
nsString& decodedString,
PRBool eatContinuations)
{
char charsetCstr[kMAX_CSNAME+1];
char *encodedCstr = nsnull;
@ -62,7 +63,8 @@ nsMimeConverter::DecodeMimePartIIStr(const nsString& header,
encodedCstr = header.ToNewCString();
if (nsnull != encodedCstr) {
// apply MIME decode.
decodedCstr = MIME_DecodeMimePartIIStr((const char *) encodedCstr, charsetCstr);
decodedCstr = MIME_DecodeMimePartIIStr((const char *) encodedCstr,
charsetCstr, eatContinuations);
if (nsnull == decodedCstr) {
// no decode needed and no default charset was specified
if (*charsetCstr == '\0') {
@ -86,9 +88,10 @@ nsMimeConverter::DecodeMimePartIIStr(const nsString& header,
nsresult
nsMimeConverter::DecodeMimePartIIStr(const char *header,
char *charset,
char **decodedString)
char **decodedString,
PRBool eatContinuations)
{
char *retString = MIME_DecodeMimePartIIStr(header, charset);
char *retString = MIME_DecodeMimePartIIStr(header, charset, eatContinuations);
if (retString == NULL)
return NS_ERROR_FAILURE;
else

Просмотреть файл

@ -47,12 +47,14 @@ public:
// Decode routine
NS_IMETHOD DecodeMimePartIIStr(const char *header,
char *charset,
char **decodedString);
char **decodedString,
PRBool eatContinuations = PR_TRUE);
// Decode routine (also converts output to unicode)
NS_IMETHOD DecodeMimePartIIStr(const nsString& header,
nsString& charset,
nsString& decodedString);
nsString& decodedString,
PRBool eatContinuations = PR_TRUE);
// Encode routine
NS_IMETHOD EncodeMimePartIIStr(const char *header,
const char *mailCharset,