Problem saving email in original charset - Bug #: 23418 - r: nhotta - a: phil

This commit is contained in:
rhp%netscape.com 2000-02-22 01:02:08 +00:00
Родитель 1d257d32f6
Коммит 6507057433
7 изменённых файлов: 76 добавлений и 30 удалений

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

@ -143,8 +143,6 @@ ConvertBufToPlainText(nsString &aConBuf)
PRUint32 converterFlags = 0;
PRUint32 wrapWidth = 72;
converterFlags |= nsIDocumentEncoder::OutputFormatted;
rv = NS_New_HTMLToTXT_SinkStream((nsIHTMLContentSink **)&sink, &convertedText, wrapWidth, converterFlags);
if (sink && NS_SUCCEEDED(rv))
{
@ -503,6 +501,7 @@ nsMessenger::SaveAs(const char* url, PRBool asFile, nsIMsgIdentity* identity)
{
nsCOMPtr<nsIFileSpec> aSpec;
PRUint32 saveAsFileType = 0; // 0 - raw, 1 = html, 2 = text;
char *defaultFile = "msgTemp.eml";
if (asFile)
{
@ -514,7 +513,7 @@ nsMessenger::SaveAs(const char* url, PRBool asFile, nsIMsgIdentity* identity)
goto done;
}
rv = fileSpec->ChooseOutputFile("Save Message", "",
rv = fileSpec->ChooseOutputFile("Save Message", defaultFile,
nsIFileSpecWithUI::eAllMailOutputFilters);
if (NS_FAILED(rv)) goto done;
char *fileName = nsnull;
@ -533,7 +532,7 @@ nsMessenger::SaveAs(const char* url, PRBool asFile, nsIMsgIdentity* identity)
}
else
{
nsFileSpec tmpFileSpec("msgTemp.eml");
nsFileSpec tmpFileSpec(defaultFile);
rv = NS_NewFileSpecWithSpec(tmpFileSpec, getter_AddRefs(aSpec));
}
if (NS_FAILED(rv)) goto done;
@ -560,10 +559,8 @@ nsMessenger::SaveAs(const char* url, PRBool asFile, nsIMsgIdentity* identity)
nsCOMPtr<nsIURI> aURL;
nsAutoString urlString = url;
if (saveAsFileType == 2) // RICHIE - text hack, ugh!
urlString += "?header=quote";
else
urlString += "?header=saveas";
// Setup the URL for a "Save As..." Operation...
urlString += "?header=saveas";
char *urlCString = urlString.ToNewCString();
rv = CreateStartupUrl(urlCString, getter_AddRefs(aURL));
@ -1418,9 +1415,10 @@ nsSaveAsListener::OnStopRequest(nsIChannel* aChannel, nsISupports* aSupport,
if (m_outputFormat == TEXT_PLAIN)
{
ConvertBufToPlainText(m_msgBuffer);
rv = ConvertFromUnicode(msgCompFileSystemCharset(), m_msgBuffer, &conBuf);
rv = nsMsgI18NSaveAsCharset(TEXT_PLAIN, (const char *)nsAutoCString(msgCompFileSystemCharset()),
m_msgBuffer.GetUnicode(), &conBuf);
if ( NS_SUCCEEDED(rv) && (conBuf) )
conLength = nsCRT::strlen(conBuf);
conLength = m_msgBuffer.Length();
}
if ( (NS_SUCCEEDED(rv)) && (conBuf) )

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

@ -553,7 +553,7 @@ nsMimeBaseEmitter::AddHeaderField(const char *field, const char *value)
{
ptr->name = nsCRT::strdup(field);
if ( (mDocHeader) || (mFormat != nsMimeOutput::nsMimeMessageSaveAs) )
if ( (mDocHeader) && (mFormat != nsMimeOutput::nsMimeMessageSaveAs) )
ptr->value = nsCRT::strdup(value);
else
ptr->value = nsAutoString(value).ToNewUTF8String();
@ -604,7 +604,7 @@ nsMimeBaseEmitter::WriteHeaderFieldHTML(const char *field, const char *value)
}
else
{
newValue = nsEscapeHTML(value);
newValue = nsCRT::strdup(value);
}
if (!newValue)

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

@ -673,7 +673,15 @@ MimeHeaders_convert_rfc1522(MimeDisplayOptions *opt,
{
char *converted = 0;
PRInt32 converted_len = 0;
const char *output_charset = "UTF-8";
const char *output_charset = nsnull;
// Ok, here is where we need to check for the type
// of output that we are doing. If we are doing Save As output
// then we should convert to the charset that lives in the headers
// for the message...if not, then go to UTF-8
if (opt->format_out != nsMimeOutput::nsMimeMessageSaveAs)
output_charset = "UTF-8";
int status =
opt->rfc1522_conversion_fn(input, input_length,
0, output_charset, /* no input charset? */

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

@ -109,6 +109,9 @@ MimeInlineImage_parse_begin (MimeObject *obj)
ct = obj->content_type;
if (!ct) ct = IMAGE_GIF; /* Can't happen? Close enough. */
// We need to separate images with HR's...
MimeObject_write_separator(obj);
img->image_data =
obj->options->image_begin(image_url, ct, obj->options->stream_closure);
PR_Free(image_url);

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

@ -577,22 +577,31 @@ mime_convert_rfc1522 (const char *input_line, PRInt32 input_length,
if (input_line[input_length] == 0) /* oh good, it's null-terminated */
line = (char *) input_line;
else
{
line = (char *) PR_MALLOC(input_length+1);
if (!line) return MIME_OUT_OF_MEMORY;
nsCRT::memcpy(line, input_line, input_length);
line[input_length] = 0;
}
{
line = (char *) PR_MALLOC(input_length+1);
if (!line) return MIME_OUT_OF_MEMORY;
nsCRT::memcpy(line, input_line, input_length);
line[input_length] = 0;
}
converted = MIME_DecodeMimePartIIStr(line, charset, PR_TRUE);
if (line != input_line)
PR_Free(line);
if (converted)
{
// If output_charset is NULL, then we should just return the decoded
// header value
if (!output_charset)
{
*output_ret = converted;
*output_size_ret = nsCRT::strlen(converted);
}
else
{
char *convertedString = NULL;
PRInt32 res = MIME_ConvertString(charset, "UTF-8", converted, &convertedString);
if ( (res != 0) || (!convertedString) )
{
@ -606,11 +615,12 @@ mime_convert_rfc1522 (const char *input_line, PRInt32 input_length,
*output_size_ret = nsCRT::strlen(convertedString);
}
}
}
else
{
*output_ret = 0;
*output_size_ret = 0;
}
{
*output_ret = 0;
*output_size_ret = 0;
}
return 0;
}
@ -869,9 +879,8 @@ mime_image_make_image_html(void *image_closure)
struct mime_image_stream_data *mid =
(struct mime_image_stream_data *) image_closure;
const char *prefix = "<P><CENTER><IMG SRC=\"";
const char *suffix = "\"></CENTER><P><BR>";
const char *suffix = "\"></CENTER><P>";
const char *url;
char *buf;

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

@ -29,6 +29,7 @@
#include "nsMimeTypes.h"
#include "nsCRT.h"
#include "nsMimeStringResources.h"
#include "mimemsg.h"
/* Way to destroy any notions of modularity or class hierarchy, Terry! */
# include "mimetpla.h"
@ -189,7 +190,30 @@ MimeObject_parse_begin (MimeObject *obj)
{
char *id = mime_part_address(obj);
if (!id) return MIME_OUT_OF_MEMORY;
obj->output_p = !nsCRT::strcmp(id, obj->options->part_to_load);
// rhp: We need to check if a part is the subpart of an RFC822 message.
// If so and this is a raw output operation, then we should mark the
// part for subsequent output.
//
obj->output_p = PR_FALSE;
PRBool exactMatch = !nsCRT::strcmp(id, obj->options->part_to_load);
if (exactMatch)
{
obj->output_p = PR_TRUE;
}
else
{
if (obj->options->format_out == nsMimeOutput::nsMimeMessageRaw)
{
if ( (obj->parent) &&
(mime_typep(obj->parent, (MimeObjectClass*) &mimeMessageClass)) )
{
obj->output_p = !nsCRT::strncmp(id, obj->options->part_to_load,
nsCRT::strlen(obj->options->part_to_load));
}
}
}
PR_Free(id);
}

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

@ -161,9 +161,13 @@ MimeInlineTextPlainFlowed_parse_eof (MimeObject *obj, PRBool abort_p)
// *don't work* status = MimeObject_write(obj, "</div>", 6, PR_FALSE);
status = MimeObject_write(obj, "</tt>", 5, PR_FALSE);
if(status<0) return status;
#ifdef DEBUG_rhp
printf("fixbredd\n");
#endif
} else {
#ifdef DEBUG_rhp
printf("propbredd");
#endif
}
return 0;