Bug #379070 --> remove nsCRT methods from libmime.
sr=bienvenu git-svn-id: svn://10.0.0.236/trunk@227840 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -34,13 +34,13 @@
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "mimecal.h"
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
#include "mimexpcom.h"
|
||||
#include "mimecth.h"
|
||||
#include "mimeobj.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
static int MimeInlineTextCalendar_parse_line (char *, PRInt32, MimeObject *);
|
||||
static int MimeInlineTextCalendar_parse_eof (MimeObject *, PRBool);
|
||||
@@ -84,7 +84,7 @@ MimeInlineTextCalendarClassInitialize(MimeInlineTextCalendarClass *clazz)
|
||||
int
|
||||
mime_TranslateCalendar(char* caldata, char** html)
|
||||
{
|
||||
*html = nsCRT::strdup("\
|
||||
*html = strdup("\
|
||||
<text=\"#000000\" bgcolor=\"#FFFFFF\" link=\"#FF0000\" vlink=\"#800080\" alink=\"#0000FF\">\
|
||||
<center><table BORDER=1 BGCOLOR=\"#CCFFFF\" ><tr>\
|
||||
<td>This libmime Content Type Handler plugin for the Content-Type <b>text/calendar\
|
||||
|
||||
@@ -41,11 +41,10 @@
|
||||
#include "prtypes.h"
|
||||
//#include "mimecth.h"
|
||||
#include "nsMimeContentTypeHandler.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
/*
|
||||
* The following macros actually implement addref, release and
|
||||
* query interface for our component.
|
||||
/*
|
||||
* The following macros actually implement addref, release and
|
||||
* query interface for our component.
|
||||
*/
|
||||
NS_IMPL_ISUPPORTS1(nsMimeContentTypeHandler, nsIMimeContentTypeHandler)
|
||||
|
||||
@@ -80,8 +79,8 @@ nsMimeContentTypeHandler::GetContentType(char **contentType)
|
||||
|
||||
// Set the output stream for processed data.
|
||||
nsresult
|
||||
nsMimeContentTypeHandler::CreateContentTypeHandlerClass(const char *content_type,
|
||||
contentTypeHandlerInitStruct *initStruct,
|
||||
nsMimeContentTypeHandler::CreateContentTypeHandlerClass(const char *content_type,
|
||||
contentTypeHandlerInitStruct *initStruct,
|
||||
MimeObjectClass **objClass)
|
||||
{
|
||||
*objClass = realCreateContentTypeHandlerClass(content_type, initStruct);
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
#include "mimexpcom.h"
|
||||
#include "mimecth.h"
|
||||
#include "mimeobj.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
// String bundles...
|
||||
@@ -57,64 +56,61 @@ static nsCOMPtr<nsIStringBundle> stringBundle = nsnull;
|
||||
static char *SMimeGetStringByID(PRInt32 aMsgId)
|
||||
{
|
||||
char *tempString = nsnull;
|
||||
nsresult res = NS_OK;
|
||||
nsresult res = NS_OK;
|
||||
|
||||
#ifdef XP_MAC
|
||||
nsCOMPtr<nsIStringBundle> stringBundle = nsnull;
|
||||
nsCOMPtr<nsIStringBundle> stringBundle = nsnull;
|
||||
#endif
|
||||
|
||||
if (!stringBundle)
|
||||
{
|
||||
static const char propertyURL[] = SMIME_PROPERTIES_URL;
|
||||
if (!stringBundle)
|
||||
{
|
||||
static const char propertyURL[] = SMIME_PROPERTIES_URL;
|
||||
|
||||
nsCOMPtr<nsIStringBundleService> sBundleService =
|
||||
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &res);
|
||||
if (NS_SUCCEEDED(res) && (nsnull != sBundleService))
|
||||
{
|
||||
res = sBundleService->CreateBundle(propertyURL, getter_AddRefs(stringBundle));
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIStringBundleService> sBundleService =
|
||||
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &res);
|
||||
if (NS_SUCCEEDED(res) && (nsnull != sBundleService))
|
||||
{
|
||||
res = sBundleService->CreateBundle(propertyURL, getter_AddRefs(stringBundle));
|
||||
}
|
||||
}
|
||||
|
||||
if (stringBundle)
|
||||
{
|
||||
PRUnichar *ptrv = nsnull;
|
||||
res = stringBundle->GetStringFromID(aMsgId, &ptrv);
|
||||
if (stringBundle)
|
||||
{
|
||||
PRUnichar *ptrv = nsnull;
|
||||
res = stringBundle->GetStringFromID(aMsgId, &ptrv);
|
||||
|
||||
if (NS_FAILED(res))
|
||||
return nsCRT::strdup("???");
|
||||
else
|
||||
if (NS_FAILED(res))
|
||||
return strdup("???");
|
||||
else
|
||||
{
|
||||
nsAutoString v;
|
||||
v.Append(ptrv);
|
||||
PR_FREEIF(ptrv);
|
||||
PR_FREEIF(ptrv);
|
||||
tempString = ToNewUTF8String(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!tempString)
|
||||
return nsCRT::strdup("???");
|
||||
return strdup("???");
|
||||
else
|
||||
return tempString;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static int MimeInlineTextSMIMEStub_parse_line (const char *, PRInt32, MimeObject *);
|
||||
static int MimeInlineTextSMIMEStub_parse_eof (MimeObject *, PRBool);
|
||||
static int MimeInlineTextSMIMEStub_parse_begin (MimeObject *obj);
|
||||
|
||||
/* This is the object definition. Note: we will set the superclass
|
||||
/* This is the object definition. Note: we will set the superclass
|
||||
to NULL and manually set this on the class creation */
|
||||
|
||||
MimeDefClass(MimeInlineTextSMIMEStub, MimeInlineTextSMIMEStubClass, mimeInlineTextSMIMEStubClass, NULL);
|
||||
MimeDefClass(MimeInlineTextSMIMEStub, MimeInlineTextSMIMEStubClass, mimeInlineTextSMIMEStubClass, NULL);
|
||||
|
||||
extern "C" MimeObjectClass *
|
||||
MIME_SMimeCreateContentTypeHandlerClass(const char *content_type,
|
||||
MIME_SMimeCreateContentTypeHandlerClass(const char *content_type,
|
||||
contentTypeHandlerInitStruct *initStruct)
|
||||
{
|
||||
MimeObjectClass *clazz = (MimeObjectClass *)&mimeInlineTextSMIMEStubClass;
|
||||
/*
|
||||
/*
|
||||
* Must set the superclass by hand.
|
||||
*/
|
||||
if (!COM_GetmimeInlineTextClass())
|
||||
@@ -138,7 +134,7 @@ MimeInlineTextSMIMEStubClassInitialize(MimeInlineTextSMIMEStubClass *clazz)
|
||||
}
|
||||
|
||||
int
|
||||
GenerateMessage(char** html)
|
||||
GenerateMessage(char** html)
|
||||
{
|
||||
nsCString temp;
|
||||
temp.Append("<BR><text=\"#000000\" bgcolor=\"#FFFFFF\" link=\"#FF0000\" vlink=\"#800080\" alink=\"#0000FF\">");
|
||||
@@ -158,16 +154,16 @@ MimeInlineTextSMIMEStub_parse_begin(MimeObject *obj)
|
||||
{
|
||||
MimeInlineTextSMIMEStubClass *clazz;
|
||||
int status = ((MimeObjectClass*)COM_GetmimeLeafClass())->parse_begin(obj);
|
||||
|
||||
if (status < 0)
|
||||
|
||||
if (status < 0)
|
||||
return status;
|
||||
|
||||
if (!obj->output_p)
|
||||
|
||||
if (!obj->output_p)
|
||||
return 0;
|
||||
if (!obj->options || !obj->options->write_html_p)
|
||||
if (!obj->options || !obj->options->write_html_p)
|
||||
return 0;
|
||||
|
||||
/* This is a fine place to write out any HTML before the real meat begins. */
|
||||
|
||||
/* This is a fine place to write out any HTML before the real meat begins. */
|
||||
|
||||
// Initialize the clazz variable...
|
||||
clazz = ((MimeInlineTextSMIMEStubClass *) obj->clazz);
|
||||
@@ -177,20 +173,20 @@ MimeInlineTextSMIMEStub_parse_begin(MimeObject *obj)
|
||||
static int
|
||||
MimeInlineTextSMIMEStub_parse_line(const char *line, PRInt32 length, MimeObject *obj)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* This routine gets fed each line of data, one at a time. We just buffer
|
||||
* it all up, to be dealt with all at once at the end.
|
||||
*/
|
||||
if (!obj->output_p)
|
||||
* it all up, to be dealt with all at once at the end.
|
||||
*/
|
||||
if (!obj->output_p)
|
||||
return 0;
|
||||
if (!obj->options || !obj->options->output_fn)
|
||||
if (!obj->options || !obj->options->output_fn)
|
||||
return 0;
|
||||
|
||||
if (!obj->options->write_html_p)
|
||||
if (!obj->options->write_html_p)
|
||||
{
|
||||
return COM_MimeObject_write(obj, line, length, PR_TRUE);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -199,28 +195,28 @@ MimeInlineTextSMIMEStub_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
{
|
||||
int status = 0;
|
||||
char* html = NULL;
|
||||
|
||||
|
||||
if (obj->closed_p) return 0;
|
||||
|
||||
/* Run parent method first, to flush out any buffered data. */
|
||||
status = ((MimeObjectClass*)COM_GetmimeInlineTextClass())->parse_eof(obj, abort_p);
|
||||
if (status < 0)
|
||||
if (status < 0)
|
||||
return status;
|
||||
|
||||
if ( (obj->options) &&
|
||||
if ( (obj->options) &&
|
||||
((obj->options->format_out == nsMimeOutput::nsMimeMessageQuoting) ||
|
||||
(obj->options->format_out == nsMimeOutput::nsMimeMessageBodyQuoting))
|
||||
)
|
||||
return 0;
|
||||
|
||||
status = GenerateMessage(&html);
|
||||
if (status < 0)
|
||||
if (status < 0)
|
||||
return status;
|
||||
|
||||
|
||||
status = COM_MimeObject_write(obj, html, PL_strlen(html), PR_TRUE);
|
||||
PR_FREEIF(html);
|
||||
if (status < 0)
|
||||
if (status < 0)
|
||||
return status;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,6 @@
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsVCardStringResources.h"
|
||||
|
||||
#include "nsCRT.h"
|
||||
#include "prprf.h"
|
||||
|
||||
// String bundles...
|
||||
@@ -209,12 +208,12 @@ static PRInt32 INTL_ConvertCharset(const char* from_charset, const char* to_char
|
||||
return -1;
|
||||
|
||||
// from to identical
|
||||
if (!nsCRT::strcasecmp(from_charset, to_charset))
|
||||
if (!PL_strcasecmp(from_charset, to_charset))
|
||||
return -1;
|
||||
|
||||
// us-ascii is a subset of utf-8
|
||||
if ((!nsCRT::strcasecmp(from_charset, "us-ascii") && !nsCRT::strcasecmp(to_charset, "UTF-8")) ||
|
||||
(!nsCRT::strcasecmp(from_charset, "UTF-8") && !nsCRT::strcasecmp(to_charset, "us-ascii")))
|
||||
if ((!PL_strcasecmp(from_charset, "us-ascii") && !PL_strcasecmp(to_charset, "UTF-8")) ||
|
||||
(!PL_strcasecmp(from_charset, "UTF-8") && !PL_strcasecmp(to_charset, "us-ascii")))
|
||||
return -1;
|
||||
|
||||
|
||||
@@ -224,7 +223,7 @@ static PRInt32 INTL_ConvertCharset(const char* from_charset, const char* to_char
|
||||
|
||||
// known bug in 4.x, it mixes Shift_JIS (or EUC-JP) and ISO-2022-JP in vCard fields
|
||||
if (NS_ERROR_MODULE_UCONV == NS_ERROR_GET_MODULE(res)) {
|
||||
if (!nsCRT::strcasecmp("ISO-2022-JP", from_charset)) {
|
||||
if (!PL_strcasecmp("ISO-2022-JP", from_charset)) {
|
||||
res = ConvertToUnicode("Shift_JIS", inBuffer, outString);
|
||||
if (NS_ERROR_MODULE_UCONV == NS_ERROR_GET_MODULE(res)) {
|
||||
res = ConvertToUnicode("EUC-JP", inBuffer, outString);
|
||||
@@ -860,7 +859,7 @@ static int OutputAdvancedVcard(MimeObject *obj, VObject *v)
|
||||
{
|
||||
namestring = vCardService->FakeCString(prop);
|
||||
if (namestring)
|
||||
if (nsCRT::strcasecmp (namestring, "TRUE") == 0)
|
||||
if (PL_strcasecmp (namestring, "TRUE") == 0)
|
||||
{
|
||||
PR_FREEIF (namestring);
|
||||
status = OutputFont(obj, PR_FALSE, "-1", NULL);
|
||||
@@ -939,16 +938,16 @@ static int OutputAdvancedVcard(MimeObject *obj, VObject *v)
|
||||
{
|
||||
namestring = vCardService->FakeCString(prop2);
|
||||
char *tString1 = NULL;
|
||||
if (nsCRT::strcmp (namestring, "0") == 0)
|
||||
if (strcmp (namestring, "0") == 0)
|
||||
{
|
||||
tString1 = VCardGetStringByID(VCARD_ADDR_DEFAULT_DLS);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nsCRT::strcmp (namestring, "1") == 0)
|
||||
if (strcmp (namestring, "1") == 0)
|
||||
tString1 = VCardGetStringByID(VCARD_ADDR_SPECIFIC_DLS);
|
||||
else
|
||||
if (nsCRT::strcmp (namestring, "2") == 0)
|
||||
if (strcmp (namestring, "2") == 0)
|
||||
tString1 = VCardGetStringByID(VCARD_ADDR_HOSTNAMEIP);
|
||||
}
|
||||
|
||||
@@ -1459,7 +1458,7 @@ static int WriteOutEachVCardPhoneProperty (MimeObject *obj, VObject* o)
|
||||
|
||||
if (vCardService->VObjectName(o))
|
||||
{
|
||||
if (nsCRT::strcasecmp (VCTelephoneProp, vCardService->VObjectName(o)) == 0)
|
||||
if (PL_strcasecmp (VCTelephoneProp, vCardService->VObjectName(o)) == 0)
|
||||
{
|
||||
if (VALUE_TYPE(o))
|
||||
{
|
||||
@@ -1546,7 +1545,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail
|
||||
|
||||
if (vCardService->VObjectName(o)) {
|
||||
|
||||
if (nsCRT::strcasecmp (VCPhotoProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (PL_strcasecmp (VCPhotoProp, vCardService->VObjectName(o)) == 0) {
|
||||
VObject* urlProp = vCardService->IsAPropertyOf(o, VCURLProp);
|
||||
if (urlProp) {
|
||||
attribName = VCardGetStringByID(VCARD_LDAP_PHOTOGRAPH);
|
||||
@@ -1560,7 +1559,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail
|
||||
}
|
||||
}
|
||||
|
||||
if (nsCRT::strcasecmp (VCBirthDateProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (PL_strcasecmp (VCBirthDateProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (VALUE_TYPE(o)) {
|
||||
attribName = VCardGetStringByID(VCARD_LDAP_BIRTHDAY);
|
||||
value = vCardService->FakeCString(o);
|
||||
@@ -1568,14 +1567,14 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail
|
||||
}
|
||||
}
|
||||
|
||||
if (nsCRT::strcasecmp (VCDeliveryLabelProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (PL_strcasecmp (VCDeliveryLabelProp, vCardService->VObjectName(o)) == 0) {
|
||||
attribName = VCardGetStringByID(VCARD_LDAP_LABEL);
|
||||
GetAddressProperties(o, &attribName);
|
||||
value = vCardService->FakeCString(o);
|
||||
goto DOWRITE;
|
||||
}
|
||||
|
||||
if (nsCRT::strcasecmp (VCEmailAddressProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (PL_strcasecmp (VCEmailAddressProp, vCardService->VObjectName(o)) == 0) {
|
||||
if ((*numEmail) != 1)
|
||||
{
|
||||
if (VALUE_TYPE(o)) {
|
||||
@@ -1588,7 +1587,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail
|
||||
}
|
||||
}
|
||||
|
||||
if (nsCRT::strcasecmp (VCFamilyNameProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (PL_strcasecmp (VCFamilyNameProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (VALUE_TYPE(o)) {
|
||||
attribName = VCardGetStringByID(VCARD_LDAP_SURNAME);
|
||||
value = vCardService->FakeCString(o);
|
||||
@@ -1596,7 +1595,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail
|
||||
}
|
||||
}
|
||||
|
||||
if (nsCRT::strcasecmp (VCGivenNameProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (PL_strcasecmp (VCGivenNameProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (VALUE_TYPE(o)) {
|
||||
attribName = VCardGetStringByID(VCARD_LDAP_GIVEN_NAME);
|
||||
value = vCardService->FakeCString(o);
|
||||
@@ -1604,7 +1603,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail
|
||||
}
|
||||
}
|
||||
|
||||
if (nsCRT::strcasecmp (VCNamePrefixesProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (PL_strcasecmp (VCNamePrefixesProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (VALUE_TYPE(o)) {
|
||||
attribName = VCardGetStringByID(VCARD_LDAP_NAME_PREFIX);
|
||||
value = vCardService->FakeCString(o);
|
||||
@@ -1612,7 +1611,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail
|
||||
}
|
||||
}
|
||||
|
||||
if (nsCRT::strcasecmp (VCNameSuffixesProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (PL_strcasecmp (VCNameSuffixesProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (VALUE_TYPE(o)) {
|
||||
attribName = VCardGetStringByID(VCARD_LDAP_NAME_SUFFIX);
|
||||
value = vCardService->FakeCString(o);
|
||||
@@ -1620,7 +1619,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail
|
||||
}
|
||||
}
|
||||
|
||||
if (nsCRT::strcasecmp (VCAdditionalNamesProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (PL_strcasecmp (VCAdditionalNamesProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (VALUE_TYPE(o)) {
|
||||
attribName = VCardGetStringByID(VCARD_LDAP_MIDDLE_NAME);
|
||||
value = vCardService->FakeCString(o);
|
||||
@@ -1628,7 +1627,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail
|
||||
}
|
||||
}
|
||||
|
||||
if (nsCRT::strcasecmp (VCMailerProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (PL_strcasecmp (VCMailerProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (VALUE_TYPE(o)) {
|
||||
attribName = VCardGetStringByID(VCARD_LDAP_MAILER);
|
||||
value = vCardService->FakeCString(o);
|
||||
@@ -1636,7 +1635,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail
|
||||
}
|
||||
}
|
||||
|
||||
if (nsCRT::strcasecmp (VCTimeZoneProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (PL_strcasecmp (VCTimeZoneProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (VALUE_TYPE(o)) {
|
||||
attribName = VCardGetStringByID(VCARD_LDAP_TZ);
|
||||
value = vCardService->FakeCString(o);
|
||||
@@ -1644,7 +1643,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail
|
||||
}
|
||||
}
|
||||
|
||||
if (nsCRT::strcasecmp (VCGeoProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (PL_strcasecmp (VCGeoProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (VALUE_TYPE(o)) {
|
||||
attribName = VCardGetStringByID(VCARD_LDAP_GEO);
|
||||
value = vCardService->FakeCString(o);
|
||||
@@ -1652,7 +1651,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail
|
||||
}
|
||||
}
|
||||
|
||||
if (nsCRT::strcasecmp (VCBusinessRoleProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (PL_strcasecmp (VCBusinessRoleProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (VALUE_TYPE(o)) {
|
||||
attribName = VCardGetStringByID(VCARD_LDAP_ROLE);
|
||||
value = vCardService->FakeCString(o);
|
||||
@@ -1660,7 +1659,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail
|
||||
}
|
||||
}
|
||||
|
||||
if (nsCRT::strcasecmp (VCLogoProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (PL_strcasecmp (VCLogoProp, vCardService->VObjectName(o)) == 0) {
|
||||
VObject* urlProp = vCardService->IsAPropertyOf(o, VCURLProp);
|
||||
if (urlProp) {
|
||||
attribName = VCardGetStringByID(VCARD_LDAP_LOGO);
|
||||
@@ -1673,12 +1672,12 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail
|
||||
}
|
||||
}
|
||||
|
||||
if (nsCRT::strcasecmp (VCAgentProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (PL_strcasecmp (VCAgentProp, vCardService->VObjectName(o)) == 0) {
|
||||
attribName = VCardGetStringByID(VCARD_LDAP_SECRETARY);
|
||||
goto DOWRITE;
|
||||
}
|
||||
|
||||
if (nsCRT::strcasecmp (VCLastRevisedProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (PL_strcasecmp (VCLastRevisedProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (VALUE_TYPE(o)) {
|
||||
attribName = VCardGetStringByID(VCARD_LDAP_REVISION);
|
||||
value = vCardService->FakeCString(o);
|
||||
@@ -1686,7 +1685,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail
|
||||
}
|
||||
}
|
||||
|
||||
if (nsCRT::strcasecmp (VCPronunciationProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (PL_strcasecmp (VCPronunciationProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (VALUE_TYPE(o)) {
|
||||
attribName = VCardGetStringByID(VCARD_LDAP_SOUND);
|
||||
value = vCardService->FakeCString(o);
|
||||
@@ -1695,7 +1694,7 @@ static int WriteOutEachVCardProperty (MimeObject *obj, VObject* o, int* numEmail
|
||||
}
|
||||
|
||||
|
||||
if (nsCRT::strcasecmp (VCVersionProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (PL_strcasecmp (VCVersionProp, vCardService->VObjectName(o)) == 0) {
|
||||
if (VALUE_TYPE(o)) {
|
||||
attribName = VCardGetStringByID(VCARD_LDAP_VERSION);
|
||||
value = vCardService->FakeCString(o);
|
||||
@@ -1840,10 +1839,10 @@ WriteLineToStream (MimeObject *obj, const char *line, PRBool aDoCharConversion)
|
||||
if (!charset)
|
||||
charset = FindCharacterSet(obj);
|
||||
|
||||
if ( (!charset) || ( (charset) && (!nsCRT::strcasecmp(charset, "us-ascii"))) )
|
||||
if ( (!charset) || ( (charset) && (!PL_strcasecmp(charset, "us-ascii"))) )
|
||||
{
|
||||
PR_Free(charset);
|
||||
charset = nsCRT::strdup("ISO-8859-1");
|
||||
charset = strdup("ISO-8859-1");
|
||||
}
|
||||
// convert from the resource charset.
|
||||
res = INTL_ConvertCharset(charset, "UTF-8", line, strlen(line),
|
||||
@@ -1925,7 +1924,7 @@ nsCOMPtr<nsIStringBundle> stringBundle = nsnull;
|
||||
res = stringBundle->GetStringFromID(aMsgId, &ptrv);
|
||||
|
||||
if (NS_FAILED(res))
|
||||
return nsCRT::strdup("???");
|
||||
return strdup("???");
|
||||
else
|
||||
{
|
||||
nsAutoString v;
|
||||
@@ -1936,7 +1935,7 @@ nsCOMPtr<nsIStringBundle> stringBundle = nsnull;
|
||||
}
|
||||
|
||||
if (!tempString)
|
||||
return nsCRT::strdup("???");
|
||||
return strdup("???");
|
||||
else
|
||||
return tempString;
|
||||
}
|
||||
|
||||
@@ -44,12 +44,12 @@
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIURI.h"
|
||||
#include "prprf.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
|
||||
extern "C" PRBool
|
||||
EmitThisHeaderForPrefSetting(PRInt32 dispType, const char *header)
|
||||
{
|
||||
if (nsMimeHeaderDisplayTypes::AllHeaders == dispType)
|
||||
if (nsMimeHeaderDisplayTypes::AllHeaders == dispType)
|
||||
return PR_TRUE;
|
||||
|
||||
if ((!header) || (!*header))
|
||||
@@ -58,9 +58,9 @@ EmitThisHeaderForPrefSetting(PRInt32 dispType, const char *header)
|
||||
if (nsMimeHeaderDisplayTypes::MicroHeaders == dispType)
|
||||
{
|
||||
if (
|
||||
(!nsCRT::strcmp(header, HEADER_SUBJECT)) ||
|
||||
(!nsCRT::strcmp(header, HEADER_FROM)) ||
|
||||
(!nsCRT::strcmp(header, HEADER_DATE))
|
||||
(!strcmp(header, HEADER_SUBJECT)) ||
|
||||
(!strcmp(header, HEADER_FROM)) ||
|
||||
(!strcmp(header, HEADER_DATE))
|
||||
)
|
||||
return PR_TRUE;
|
||||
else
|
||||
@@ -70,24 +70,24 @@ EmitThisHeaderForPrefSetting(PRInt32 dispType, const char *header)
|
||||
if (nsMimeHeaderDisplayTypes::NormalHeaders == dispType)
|
||||
{
|
||||
if (
|
||||
(!nsCRT::strcmp(header, HEADER_DATE)) ||
|
||||
(!nsCRT::strcmp(header, HEADER_TO)) ||
|
||||
(!nsCRT::strcmp(header, HEADER_SUBJECT)) ||
|
||||
(!nsCRT::strcmp(header, HEADER_SENDER)) ||
|
||||
(!nsCRT::strcmp(header, HEADER_RESENT_TO)) ||
|
||||
(!nsCRT::strcmp(header, HEADER_RESENT_SENDER)) ||
|
||||
(!nsCRT::strcmp(header, HEADER_RESENT_FROM)) ||
|
||||
(!nsCRT::strcmp(header, HEADER_RESENT_CC)) ||
|
||||
(!nsCRT::strcmp(header, HEADER_REPLY_TO)) ||
|
||||
(!nsCRT::strcmp(header, HEADER_REFERENCES)) ||
|
||||
(!nsCRT::strcmp(header, HEADER_NEWSGROUPS)) ||
|
||||
(!nsCRT::strcmp(header, HEADER_MESSAGE_ID)) ||
|
||||
(!nsCRT::strcmp(header, HEADER_FROM)) ||
|
||||
(!nsCRT::strcmp(header, HEADER_FOLLOWUP_TO)) ||
|
||||
(!nsCRT::strcmp(header, HEADER_CC)) ||
|
||||
(!nsCRT::strcmp(header, HEADER_ORGANIZATION)) ||
|
||||
(!nsCRT::strcmp(header, HEADER_REPLY_TO)) ||
|
||||
(!nsCRT::strcmp(header, HEADER_BCC))
|
||||
(!strcmp(header, HEADER_DATE)) ||
|
||||
(!strcmp(header, HEADER_TO)) ||
|
||||
(!strcmp(header, HEADER_SUBJECT)) ||
|
||||
(!strcmp(header, HEADER_SENDER)) ||
|
||||
(!strcmp(header, HEADER_RESENT_TO)) ||
|
||||
(!strcmp(header, HEADER_RESENT_SENDER)) ||
|
||||
(!strcmp(header, HEADER_RESENT_FROM)) ||
|
||||
(!strcmp(header, HEADER_RESENT_CC)) ||
|
||||
(!strcmp(header, HEADER_REPLY_TO)) ||
|
||||
(!strcmp(header, HEADER_REFERENCES)) ||
|
||||
(!strcmp(header, HEADER_NEWSGROUPS)) ||
|
||||
(!strcmp(header, HEADER_MESSAGE_ID)) ||
|
||||
(!strcmp(header, HEADER_FROM)) ||
|
||||
(!strcmp(header, HEADER_FOLLOWUP_TO)) ||
|
||||
(!strcmp(header, HEADER_CC)) ||
|
||||
(!strcmp(header, HEADER_ORGANIZATION)) ||
|
||||
(!strcmp(header, HEADER_REPLY_TO)) ||
|
||||
(!strcmp(header, HEADER_BCC))
|
||||
)
|
||||
return PR_TRUE;
|
||||
else
|
||||
|
||||
@@ -327,7 +327,7 @@ nsMimeBaseEmitter::LocalizeHeaderName(const char *aHeaderName, const char *aDefa
|
||||
if (retVal)
|
||||
return retVal;
|
||||
else
|
||||
return nsCRT::strdup(aDefaultName);
|
||||
return strdup(aDefaultName);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -396,9 +396,9 @@ nsMimeBaseEmitter::StartAttachment(const char *name, const char *contentType, co
|
||||
{
|
||||
++mAttachCount;
|
||||
|
||||
mCurrentAttachment->displayName = nsCRT::strdup(name);
|
||||
mCurrentAttachment->urlSpec = nsCRT::strdup(url);
|
||||
mCurrentAttachment->contentType = nsCRT::strdup(contentType);
|
||||
mCurrentAttachment->displayName = strdup(name);
|
||||
mCurrentAttachment->urlSpec = strdup(url);
|
||||
mCurrentAttachment->contentType = strdup(contentType);
|
||||
mCurrentAttachment->isExternalAttachment = aIsExternalAttachment;
|
||||
}
|
||||
|
||||
@@ -544,7 +544,7 @@ nsMimeBaseEmitter::GetHeaderValue(const char *aHeaderName)
|
||||
if ( (!headerInfo) || (!headerInfo->name) || (!(*headerInfo->name)) )
|
||||
continue;
|
||||
|
||||
if (!nsCRT::strcasecmp(aHeaderName, headerInfo->name))
|
||||
if (!PL_strcasecmp(aHeaderName, headerInfo->name))
|
||||
{
|
||||
retVal = headerInfo->value;
|
||||
break;
|
||||
@@ -656,8 +656,8 @@ nsMimeBaseEmitter::AddHeaderField(const char *field, const char *value)
|
||||
headerInfoType *ptr = (headerInfoType *) PR_NEWZAP(headerInfoType);
|
||||
if ( (ptr) && tPtr)
|
||||
{
|
||||
ptr->name = nsCRT::strdup(field);
|
||||
ptr->value = nsCRT::strdup(value);
|
||||
ptr->name = strdup(field);
|
||||
ptr->value = strdup(value);
|
||||
tPtr->AppendElement(ptr);
|
||||
}
|
||||
|
||||
@@ -716,7 +716,7 @@ nsMimeBaseEmitter::WriteHeaderFieldHTML(const char *field, const char *value)
|
||||
}
|
||||
else
|
||||
{
|
||||
newValue = nsCRT::strdup(value);
|
||||
newValue = strdup(value);
|
||||
}
|
||||
|
||||
if (!newValue)
|
||||
@@ -879,11 +879,11 @@ nsMimeBaseEmitter::DumpRestOfHeaders()
|
||||
(!headerInfo->value) || (!(*headerInfo->value)))
|
||||
continue;
|
||||
|
||||
if ( (!nsCRT::strcasecmp(HEADER_SUBJECT, headerInfo->name)) ||
|
||||
(!nsCRT::strcasecmp(HEADER_DATE, headerInfo->name)) ||
|
||||
(!nsCRT::strcasecmp(HEADER_FROM, headerInfo->name)) ||
|
||||
(!nsCRT::strcasecmp(HEADER_TO, headerInfo->name)) ||
|
||||
(!nsCRT::strcasecmp(HEADER_CC, headerInfo->name)) )
|
||||
if ( (!PL_strcasecmp(HEADER_SUBJECT, headerInfo->name)) ||
|
||||
(!PL_strcasecmp(HEADER_DATE, headerInfo->name)) ||
|
||||
(!PL_strcasecmp(HEADER_FROM, headerInfo->name)) ||
|
||||
(!PL_strcasecmp(HEADER_TO, headerInfo->name)) ||
|
||||
(!PL_strcasecmp(HEADER_CC, headerInfo->name)) )
|
||||
continue;
|
||||
|
||||
WriteHeaderFieldHTML(headerInfo->name, headerInfo->value);
|
||||
|
||||
@@ -86,7 +86,7 @@ nsresult nsMimeHtmlDisplayEmitter::Init()
|
||||
PRBool nsMimeHtmlDisplayEmitter::BroadCastHeadersAndAttachments()
|
||||
{
|
||||
// try to get a header sink if there is one....
|
||||
nsCOMPtr<nsIMsgHeaderSink> headerSink;
|
||||
nsCOMPtr<nsIMsgHeaderSink> headerSink;
|
||||
nsresult rv = GetHeaderSink(getter_AddRefs(headerSink));
|
||||
if (NS_SUCCEEDED(rv) && headerSink && mDocHeader)
|
||||
return PR_TRUE;
|
||||
@@ -94,7 +94,7 @@ PRBool nsMimeHtmlDisplayEmitter::BroadCastHeadersAndAttachments()
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsresult
|
||||
nsMimeHtmlDisplayEmitter::WriteHeaderFieldHTMLPrefix()
|
||||
{
|
||||
if (!BroadCastHeadersAndAttachments() || (mFormat == nsMimeOutput::nsMimeMessagePrintOutput))
|
||||
@@ -189,34 +189,34 @@ nsresult nsMimeHtmlDisplayEmitter::BroadcastHeaders(nsIMsgHeaderSink * aHeaderSi
|
||||
const char * headerValue = headerInfo->value;
|
||||
|
||||
// optimization: if we aren't in view all header view mode, we only show a small set of the total # of headers.
|
||||
// don't waste time sending those out to the UI since the UI is going to ignore them anyway.
|
||||
if (aHeaderMode != VIEW_ALL_HEADERS && (mFormat != nsMimeOutput::nsMimeMessageFilterSniffer))
|
||||
// don't waste time sending those out to the UI since the UI is going to ignore them anyway.
|
||||
if (aHeaderMode != VIEW_ALL_HEADERS && (mFormat != nsMimeOutput::nsMimeMessageFilterSniffer))
|
||||
{
|
||||
nsDependentCString headerStr(headerInfo->name);
|
||||
if (nsCRT::strcasecmp("to", headerInfo->name) && nsCRT::strcasecmp("from", headerInfo->name) &&
|
||||
nsCRT::strcasecmp("cc", headerInfo->name) && nsCRT::strcasecmp("newsgroups", headerInfo->name) &&
|
||||
nsCRT::strcasecmp("bcc", headerInfo->name) && nsCRT::strcasecmp("followup-to", headerInfo->name) &&
|
||||
nsCRT::strcasecmp("reply-to", headerInfo->name) && nsCRT::strcasecmp("subject", headerInfo->name) &&
|
||||
nsCRT::strcasecmp("organization", headerInfo->name) && nsCRT::strcasecmp("user-agent", headerInfo->name) &&
|
||||
nsCRT::strcasecmp("content-base", headerInfo->name) && nsCRT::strcasecmp("sender", headerInfo->name) &&
|
||||
nsCRT::strcasecmp("date", headerInfo->name) && nsCRT::strcasecmp("x-mailer", headerInfo->name) &&
|
||||
nsCRT::strcasecmp("content-type", headerInfo->name) && nsCRT::strcasecmp("message-id", headerInfo->name) &&
|
||||
nsCRT::strcasecmp("x-newsreader", headerInfo->name) && nsCRT::strcasecmp("x-mimeole", headerInfo->name) &&
|
||||
if (PL_strcasecmp("to", headerInfo->name) && PL_strcasecmp("from", headerInfo->name) &&
|
||||
PL_strcasecmp("cc", headerInfo->name) && PL_strcasecmp("newsgroups", headerInfo->name) &&
|
||||
PL_strcasecmp("bcc", headerInfo->name) && PL_strcasecmp("followup-to", headerInfo->name) &&
|
||||
PL_strcasecmp("reply-to", headerInfo->name) && PL_strcasecmp("subject", headerInfo->name) &&
|
||||
PL_strcasecmp("organization", headerInfo->name) && PL_strcasecmp("user-agent", headerInfo->name) &&
|
||||
PL_strcasecmp("content-base", headerInfo->name) && PL_strcasecmp("sender", headerInfo->name) &&
|
||||
PL_strcasecmp("date", headerInfo->name) && PL_strcasecmp("x-mailer", headerInfo->name) &&
|
||||
PL_strcasecmp("content-type", headerInfo->name) && PL_strcasecmp("message-id", headerInfo->name) &&
|
||||
PL_strcasecmp("x-newsreader", headerInfo->name) && PL_strcasecmp("x-mimeole", headerInfo->name) &&
|
||||
// make headerStr lower case because IndexOf is case-sensitive
|
||||
(!extraExpandedHeadersArray.Count() || (ToLowerCase(headerStr),
|
||||
extraExpandedHeadersArray.IndexOf(headerStr) == kNotFound)))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!nsCRT::strcasecmp("Date", headerInfo->name) && !displayOriginalDate)
|
||||
if (!PL_strcasecmp("Date", headerInfo->name) && !displayOriginalDate)
|
||||
{
|
||||
GenerateDateString(headerValue, convertedDateString);
|
||||
GenerateDateString(headerValue, convertedDateString);
|
||||
headerValueArray.AppendCString(convertedDateString);
|
||||
}
|
||||
else // append the header value as is
|
||||
headerValueArray.AppendCString(nsCString(headerValue));
|
||||
|
||||
// XXX: TODO If nsCStringArray were converted over to take nsACStrings instead of nsCStrings, we can just
|
||||
// XXX: TODO If nsCStringArray were converted over to take nsACStrings instead of nsCStrings, we can just
|
||||
// wrap these strings with a nsDependentCString which would avoid making a duplicate copy of the string
|
||||
// like we are doing here....
|
||||
headerNameArray.AppendCString(nsCString(headerInfo->name));
|
||||
@@ -249,7 +249,7 @@ NS_IMETHODIMP nsMimeHtmlDisplayEmitter::WriteHTMLHeaders()
|
||||
}
|
||||
else
|
||||
mFirstHeaders = PR_FALSE;
|
||||
|
||||
|
||||
PRBool bFromNewsgroups = PR_FALSE;
|
||||
for (PRInt32 j=0; j < mHeaderArray->Count(); j++)
|
||||
{
|
||||
@@ -257,7 +257,7 @@ NS_IMETHODIMP nsMimeHtmlDisplayEmitter::WriteHTMLHeaders()
|
||||
if (!(headerInfo && headerInfo->name && *headerInfo->name))
|
||||
continue;
|
||||
|
||||
if (!nsCRT::strcasecmp("Newsgroups", headerInfo->name))
|
||||
if (!PL_strcasecmp("Newsgroups", headerInfo->name))
|
||||
{
|
||||
bFromNewsgroups = PR_TRUE;
|
||||
break;
|
||||
@@ -265,7 +265,7 @@ NS_IMETHODIMP nsMimeHtmlDisplayEmitter::WriteHTMLHeaders()
|
||||
}
|
||||
|
||||
// try to get a header sink if there is one....
|
||||
nsCOMPtr<nsIMsgHeaderSink> headerSink;
|
||||
nsCOMPtr<nsIMsgHeaderSink> headerSink;
|
||||
nsresult rv = GetHeaderSink(getter_AddRefs(headerSink));
|
||||
|
||||
if (headerSink)
|
||||
@@ -311,10 +311,10 @@ nsresult nsMimeHtmlDisplayEmitter::GenerateDateString(const char * dateString, n
|
||||
{
|
||||
// same day...
|
||||
dateFormat = kDateFormatNone;
|
||||
}
|
||||
}
|
||||
// the following chunk of code causes us to show a day instead of a number if the message was received
|
||||
// within the last 7 days. i.e. Mon 5:10pm. We need to add a preference so folks to can enable this behavior
|
||||
// if they want it.
|
||||
// if they want it.
|
||||
/*
|
||||
else if (LL_CMP(currentTime, >, dateOfMsg))
|
||||
{
|
||||
@@ -325,12 +325,12 @@ nsresult nsMimeHtmlDisplayEmitter::GenerateDateString(const char * dateString, n
|
||||
|
||||
PRInt64 diff;
|
||||
LL_SUB(diff, currentTime, dateOfMsg);
|
||||
if (LL_CMP(diff, <=, microSecondsInDays)) // within the same week
|
||||
if (LL_CMP(diff, <=, microSecondsInDays)) // within the same week
|
||||
dateFormat = kDateFormatWeekday;
|
||||
}
|
||||
*/
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = mDateFormater->FormatPRTime(nsnull /* nsILocale* locale */,
|
||||
dateFormat,
|
||||
kTimeFormatNoSeconds,
|
||||
@@ -387,11 +387,11 @@ nsMimeHtmlDisplayEmitter::StartAttachment(const char *name,
|
||||
PRBool aIsExternalAttachment)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIMsgHeaderSink> headerSink;
|
||||
nsCOMPtr<nsIMsgHeaderSink> headerSink;
|
||||
rv = GetHeaderSink(getter_AddRefs(headerSink));
|
||||
|
||||
|
||||
if (NS_SUCCEEDED(rv) && headerSink)
|
||||
{
|
||||
{
|
||||
char * escapedUrl = nsEscape(url, url_Path);
|
||||
nsCString uriString;
|
||||
|
||||
@@ -430,7 +430,7 @@ nsMimeHtmlDisplayEmitter::StartAttachment(const char *name,
|
||||
unicodeHeaderValue.get(), uriString.get(),
|
||||
aIsExternalAttachment);
|
||||
|
||||
nsCRT::free(escapedUrl);
|
||||
NS_Free(escapedUrl);
|
||||
mSkipAttachment = PR_TRUE;
|
||||
}
|
||||
else if (mFormat == nsMimeOutput::nsMimeMessagePrintOutput)
|
||||
@@ -450,7 +450,7 @@ nsMimeHtmlDisplayEmitter::StartAttachment(const char *name,
|
||||
}
|
||||
|
||||
// Attachment handling routines
|
||||
// Ok, we are changing the way we handle these now...It used to be that we output
|
||||
// Ok, we are changing the way we handle these now...It used to be that we output
|
||||
// HTML to make a clickable link, etc... but now, this should just be informational
|
||||
// and only show up during printing
|
||||
// XXX should they also show up during quoting?
|
||||
@@ -553,7 +553,7 @@ nsresult
|
||||
nsMimeHtmlDisplayEmitter::EndAllAttachments()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIMsgHeaderSink> headerSink;
|
||||
nsCOMPtr<nsIMsgHeaderSink> headerSink;
|
||||
rv = GetHeaderSink(getter_AddRefs(headerSink));
|
||||
if (headerSink)
|
||||
headerSink->OnEndAllAttachments();
|
||||
@@ -575,7 +575,7 @@ nsMimeHtmlDisplayEmitter::EndBody()
|
||||
UtilityWriteCRLF("</body>");
|
||||
UtilityWriteCRLF("</html>");
|
||||
}
|
||||
nsCOMPtr<nsIMsgHeaderSink> headerSink;
|
||||
nsCOMPtr<nsIMsgHeaderSink> headerSink;
|
||||
nsresult rv = GetHeaderSink(getter_AddRefs(headerSink));
|
||||
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl (do_QueryInterface(mURL, &rv));
|
||||
if (headerSink)
|
||||
|
||||
@@ -47,7 +47,6 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
/*
|
||||
* nsMimeXmlEmitter definitions....
|
||||
@@ -87,11 +86,11 @@ nsMimeXmlEmitter::WriteXMLHeader(const char *msgID)
|
||||
{
|
||||
if ( (!msgID) || (!*msgID) )
|
||||
msgID = "none";
|
||||
|
||||
|
||||
char *newValue = nsEscapeHTML(msgID);
|
||||
if (!newValue)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
||||
UtilityWrite("<?xml version=\"1.0\"?>");
|
||||
|
||||
UtilityWriteCRLF("<?xml-stylesheet href=\"chrome://messenger/skin/messageBody.css\" type=\"text/css\"?>");
|
||||
@@ -113,7 +112,7 @@ nsMimeXmlEmitter::WriteXMLTag(const char *tagName, const char *value)
|
||||
|
||||
char *upCaseTag = NULL;
|
||||
char *newValue = nsEscapeHTML(value);
|
||||
if (!newValue)
|
||||
if (!newValue)
|
||||
return NS_OK;
|
||||
|
||||
nsString newTagName;
|
||||
@@ -149,7 +148,7 @@ nsMimeXmlEmitter::WriteXMLTag(const char *tagName, const char *value)
|
||||
UtilityWrite(newValue);
|
||||
UtilityWrite("</header>");
|
||||
|
||||
nsCRT::free(upCaseTag);
|
||||
NS_Free(upCaseTag);
|
||||
PR_FREEIF(newValue);
|
||||
|
||||
return NS_OK;
|
||||
@@ -164,7 +163,7 @@ nsMimeXmlEmitter::StartHeader(PRBool rootMailHeader, PRBool headerOnly, const ch
|
||||
WriteXMLHeader(msgID);
|
||||
UtilityWrite("<mailheader>");
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
@@ -181,7 +180,7 @@ nsresult
|
||||
nsMimeXmlEmitter::EndHeader()
|
||||
{
|
||||
UtilityWrite("</mailheader>");
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -49,7 +49,6 @@
|
||||
#include "prlog.h"
|
||||
#include "prprf.h"
|
||||
#include "plstr.h"
|
||||
#include "nsCRT.h"
|
||||
#include "comi18n.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIStringCharsetDetector.h"
|
||||
@@ -214,7 +213,7 @@ PRInt32 generate_encodedwords(char *pUTF8, const char *charset, char method, cha
|
||||
{
|
||||
nsCOMPtr <nsICharsetAlias> calias = do_GetService(NS_CHARSETALIAS_CONTRACTID, &rv);
|
||||
nsCOMPtr <nsIAtom> charsetAtom;
|
||||
charset = !nsCRT::strcasecmp(charset, "us-ascii") ? "ISO-8859-1" : charset;
|
||||
charset = !PL_strcasecmp(charset, "us-ascii") ? "ISO-8859-1" : charset;
|
||||
rv = calias->GetPreferred(nsDependentCString(charset),
|
||||
_charset);
|
||||
if (NS_FAILED(rv)) {
|
||||
@@ -236,7 +235,7 @@ PRInt32 generate_encodedwords(char *pUTF8, const char *charset, char method, cha
|
||||
encodedword_headlen = strlen(encodedword_head);
|
||||
|
||||
// Load HANKAKU-KANA prefrence and cache it.
|
||||
if (!nsCRT::strcasecmp("ISO-2022-JP", charset)) {
|
||||
if (!PL_strcasecmp("ISO-2022-JP", charset)) {
|
||||
static PRInt32 conv_kana = -1;
|
||||
if (conv_kana < 0) {
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||
@@ -252,7 +251,7 @@ PRInt32 generate_encodedwords(char *pUTF8, const char *charset, char method, cha
|
||||
do_CreateInstance(NS_HANKAKUTOZENKAKU_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsString text(pUCS2), result;
|
||||
rv = textTransform->Change(pUCS2, nsCRT::strlen(pUCS2), result);
|
||||
rv = textTransform->Change(pUCS2, NS_strlen(pUCS2), result);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (_pUCS2)
|
||||
nsMemory::Free(_pUCS2);
|
||||
@@ -267,8 +266,8 @@ PRInt32 generate_encodedwords(char *pUTF8, const char *charset, char method, cha
|
||||
// Create an instance of charset converter and initialize it
|
||||
conv = do_CreateInstance(NS_SAVEASCHARSET_CONTRACTID, &rv);
|
||||
if(NS_SUCCEEDED(rv)) {
|
||||
rv = conv->Init(charset,
|
||||
nsISaveAsCharset::attr_FallbackQuestionMark + nsISaveAsCharset::attr_EntityAfterCharsetConv,
|
||||
rv = conv->Init(charset,
|
||||
nsISaveAsCharset::attr_FallbackQuestionMark + nsISaveAsCharset::attr_EntityAfterCharsetConv,
|
||||
nsIEntityConverter::transliterate);
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
@@ -489,7 +488,7 @@ RFC822AddressList * construct_addresslist(char *s)
|
||||
if (--comment == 0) {
|
||||
*s = '\0';
|
||||
PR_FREEIF(list->displayname);
|
||||
list->displayname = nsCRT::strdup(displayname);
|
||||
list->displayname = strdup(displayname);
|
||||
list->asciionly = intlmime_only_ascii_str(displayname);
|
||||
*s = ')';
|
||||
}
|
||||
@@ -506,7 +505,7 @@ RFC822AddressList * construct_addresslist(char *s)
|
||||
char tmp = *(s+1);
|
||||
*(s+1) = '\0';
|
||||
PR_FREEIF(list->displayname);
|
||||
list->displayname = nsCRT::strdup(displayname);
|
||||
list->displayname = strdup(displayname);
|
||||
list->asciionly = intlmime_only_ascii_str(displayname);
|
||||
*(s+1) = tmp;
|
||||
}
|
||||
@@ -525,7 +524,7 @@ RFC822AddressList * construct_addresslist(char *s)
|
||||
tmp = *++e;
|
||||
*e = '\0';
|
||||
PR_FREEIF(list->displayname);
|
||||
list->displayname = nsCRT::strdup(displayname);
|
||||
list->displayname = strdup(displayname);
|
||||
list->asciionly = intlmime_only_ascii_str(displayname);
|
||||
*e = tmp;
|
||||
}
|
||||
@@ -536,7 +535,7 @@ RFC822AddressList * construct_addresslist(char *s)
|
||||
tmp = *(s+1);
|
||||
*(s+1) = '\0';
|
||||
PR_FREEIF(list->addrspec);
|
||||
list->addrspec = nsCRT::strdup(addrspec);
|
||||
list->addrspec = strdup(addrspec);
|
||||
*(s+1) = tmp;
|
||||
}
|
||||
continue;
|
||||
@@ -548,7 +547,7 @@ RFC822AddressList * construct_addresslist(char *s)
|
||||
/* deal with addr-spec only address */
|
||||
if (!addrspec && displayname) {
|
||||
*s = '\0';
|
||||
list->addrspec = nsCRT::strdup(displayname);
|
||||
list->addrspec = strdup(displayname);
|
||||
/* and don't forget to free the display name in the list, in that case it's bogus */
|
||||
PR_FREEIF(list->displayname);
|
||||
}
|
||||
@@ -574,7 +573,7 @@ RFC822AddressList * construct_addresslist(char *s)
|
||||
/* deal with addr-spec only address comes at last */
|
||||
if (!addrspec && displayname)
|
||||
{
|
||||
list->addrspec = nsCRT::strdup(displayname);
|
||||
list->addrspec = strdup(displayname);
|
||||
/* and don't forget to free the display name in the list, in that case it's bogus */
|
||||
PR_FREEIF(list->displayname);
|
||||
}
|
||||
@@ -582,7 +581,7 @@ RFC822AddressList * construct_addresslist(char *s)
|
||||
return listhead;
|
||||
}
|
||||
|
||||
static
|
||||
static
|
||||
char * apply_rfc2047_encoding(const char *_src, PRBool structured, const char *charset, PRInt32 cursor, PRInt32 foldlen)
|
||||
{
|
||||
RFC822AddressList *listhead, *list;
|
||||
@@ -596,7 +595,7 @@ char * apply_rfc2047_encoding(const char *_src, PRBool structured, const char *c
|
||||
//<TAB>=?<charset>?<B/Q>?...?=<CRLF>
|
||||
PRInt32 perLineOverhead = strlen(charset) + 10;
|
||||
|
||||
if (perLineOverhead > foldlen || (src = src_head = nsCRT::strdup(_src)) == nsnull)
|
||||
if (perLineOverhead > foldlen || (src = src_head = strdup(_src)) == nsnull)
|
||||
return nsnull;
|
||||
|
||||
/* allocate enough buffer for conversion, this way it can avoid
|
||||
@@ -680,7 +679,7 @@ char * apply_rfc2047_encoding(const char *_src, PRBool structured, const char *c
|
||||
}
|
||||
else {
|
||||
char *spacepos = nsnull, *org_output = output;
|
||||
/* show some mercy to stupid ML systems which don't know
|
||||
/* show some mercy to stupid ML systems which don't know
|
||||
how to respect MIME encoded subject */
|
||||
for (char *p = src; *p && !(*p & 0x80); p++) {
|
||||
if (*p == 0x20 || *p == TAB)
|
||||
@@ -725,7 +724,7 @@ extern "C" {
|
||||
#define PUBLIC
|
||||
|
||||
|
||||
extern "C" char *MIME_DecodeMimeHeader(const char *header,
|
||||
extern "C" char *MIME_DecodeMimeHeader(const char *header,
|
||||
const char *default_charset,
|
||||
PRBool override_charset,
|
||||
PRBool eatContinuations)
|
||||
@@ -735,12 +734,12 @@ extern "C" char *MIME_DecodeMimeHeader(const char *header,
|
||||
if (NS_FAILED(rv))
|
||||
return nsnull;
|
||||
nsCAutoString result;
|
||||
rv = mimehdrpar->DecodeRFC2047Header(header, default_charset, override_charset,
|
||||
rv = mimehdrpar->DecodeRFC2047Header(header, default_charset, override_charset,
|
||||
eatContinuations, result);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return nsCRT::strdup(result.get());
|
||||
return ToNewCString(result);
|
||||
return nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
char *MIME_EncodeMimePartIIStr(const char* header, PRBool structured, const char* mailCharset, const PRInt32 fieldNameLen, const PRInt32 encodedWordSize)
|
||||
{
|
||||
@@ -781,40 +780,40 @@ MIME_detect_charset(const char *aBuf, PRInt32 aLength, const char** aCharset)
|
||||
}
|
||||
|
||||
//Get unicode decoder(from inputcharset to unicode) for aInputCharset
|
||||
nsresult
|
||||
nsresult
|
||||
MIME_get_unicode_decoder(const char* aInputCharset, nsIUnicodeDecoder **aDecoder)
|
||||
{
|
||||
nsresult res;
|
||||
|
||||
// get charset converters.
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm =
|
||||
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &res);
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm =
|
||||
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &res);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
|
||||
// create a decoder (conv to unicode), ok if failed if we do auto detection
|
||||
if (!*aInputCharset || !nsCRT::strcasecmp("us-ascii", aInputCharset))
|
||||
if (!*aInputCharset || !PL_strcasecmp("us-ascii", aInputCharset))
|
||||
res = ccm->GetUnicodeDecoderRaw("ISO-8859-1", aDecoder);
|
||||
else
|
||||
res = ccm->GetUnicodeDecoder(aInputCharset, aDecoder);
|
||||
}
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
//Get unicode encoder(from unicode to inputcharset) for aOutputCharset
|
||||
nsresult
|
||||
nsresult
|
||||
MIME_get_unicode_encoder(const char* aOutputCharset, nsIUnicodeEncoder **aEncoder)
|
||||
{
|
||||
nsresult res;
|
||||
|
||||
// get charset converters.
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm =
|
||||
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &res);
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm =
|
||||
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &res);
|
||||
if (NS_SUCCEEDED(res) && *aOutputCharset) {
|
||||
// create a encoder (conv from unicode)
|
||||
res = ccm->GetUnicodeEncoder(aOutputCharset, aEncoder);
|
||||
}
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,6 @@
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
#include "prlog.h"
|
||||
#include "nsCRT.h"
|
||||
#include "msgCore.h"
|
||||
#include "nsMimeStringResources.h"
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
#include "nsICMSDecoder.h"
|
||||
#include "mimecms.h"
|
||||
#include "mimemsig.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nspr.h"
|
||||
#include "nsEscape.h"
|
||||
#include "mimemsg.h"
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
#include "prlog.h"
|
||||
#include "nsCRT.h"
|
||||
#include "prio.h"
|
||||
#include "mimecont.h"
|
||||
#include "nsMimeStringResources.h"
|
||||
|
||||
@@ -43,13 +43,12 @@
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
#include "prlog.h"
|
||||
#include "nsCRT.h"
|
||||
#include "mimemult.h"
|
||||
|
||||
|
||||
#define MIME_SUPERCLASS mimeContainerClass
|
||||
MimeDefClass(MimeEncrypted, MimeEncryptedClass, mimeEncryptedClass,
|
||||
&MIME_SUPERCLASS);
|
||||
&MIME_SUPERCLASS);
|
||||
|
||||
static int MimeEncrypted_initialize (MimeObject *);
|
||||
static void MimeEncrypted_finalize (MimeObject *);
|
||||
@@ -103,51 +102,51 @@ MimeEncrypted_parse_begin (MimeObject *obj)
|
||||
MimeDecoderData *(*fn) (nsresult (*) (const char*, PRInt32, void*), void*) = 0;
|
||||
|
||||
if (enc->crypto_closure)
|
||||
return -1;
|
||||
return -1;
|
||||
|
||||
enc->crypto_closure = (((MimeEncryptedClass *) obj->clazz)->crypto_init) (obj, MimeHandleDecryptedOutput, obj);
|
||||
if (!enc->crypto_closure)
|
||||
return -1;
|
||||
return -1;
|
||||
|
||||
|
||||
/* (Mostly duplicated from MimeLeaf, see comments in mimecryp.h.)
|
||||
Initialize a decoder if necessary.
|
||||
*/
|
||||
if (!obj->encoding)
|
||||
;
|
||||
else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_BASE64))
|
||||
fn = &MimeB64DecoderInit;
|
||||
else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_QUOTED_PRINTABLE))
|
||||
;
|
||||
else if (!PL_strcasecmp(obj->encoding, ENCODING_BASE64))
|
||||
fn = &MimeB64DecoderInit;
|
||||
else if (!PL_strcasecmp(obj->encoding, ENCODING_QUOTED_PRINTABLE))
|
||||
{
|
||||
enc->decoder_data =
|
||||
MimeQPDecoderInit (/* The (int (*) ...) cast is to turn the `void' argument
|
||||
into `MimeObject'. */
|
||||
((nsresult (*) (const char *, PRInt32, void *))
|
||||
((MimeEncryptedClass *)obj->clazz)->parse_decoded_buffer),
|
||||
obj);
|
||||
MimeQPDecoderInit (/* The (int (*) ...) cast is to turn the `void' argument
|
||||
into `MimeObject'. */
|
||||
((nsresult (*) (const char *, PRInt32, void *))
|
||||
((MimeEncryptedClass *)obj->clazz)->parse_decoded_buffer),
|
||||
obj);
|
||||
|
||||
if (!enc->decoder_data)
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE) ||
|
||||
!nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE2) ||
|
||||
!nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE3) ||
|
||||
!nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE4))
|
||||
fn = &MimeUUDecoderInit;
|
||||
else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_YENCODE))
|
||||
else if (!PL_strcasecmp(obj->encoding, ENCODING_UUENCODE) ||
|
||||
!PL_strcasecmp(obj->encoding, ENCODING_UUENCODE2) ||
|
||||
!PL_strcasecmp(obj->encoding, ENCODING_UUENCODE3) ||
|
||||
!PL_strcasecmp(obj->encoding, ENCODING_UUENCODE4))
|
||||
fn = &MimeUUDecoderInit;
|
||||
else if (!PL_strcasecmp(obj->encoding, ENCODING_YENCODE))
|
||||
fn = &MimeYDecoderInit;
|
||||
if (fn)
|
||||
{
|
||||
enc->decoder_data =
|
||||
fn (/* The (int (*) ...) cast is to turn the `void' argument
|
||||
into `MimeObject'. */
|
||||
((nsresult (*) (const char *, PRInt32, void *))
|
||||
((MimeEncryptedClass *)obj->clazz)->parse_decoded_buffer),
|
||||
obj);
|
||||
{
|
||||
enc->decoder_data =
|
||||
fn (/* The (int (*) ...) cast is to turn the `void' argument
|
||||
into `MimeObject'. */
|
||||
((nsresult (*) (const char *, PRInt32, void *))
|
||||
((MimeEncryptedClass *)obj->clazz)->parse_decoded_buffer),
|
||||
obj);
|
||||
|
||||
if (!enc->decoder_data)
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
if (!enc->decoder_data)
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_begin(obj);
|
||||
}
|
||||
@@ -164,15 +163,15 @@ MimeEncrypted_parse_buffer (const char *buffer, PRInt32 size, MimeObject *obj)
|
||||
if (obj->closed_p) return -1;
|
||||
|
||||
/* Don't consult output_p here, since at this point we're behaving as a
|
||||
simple container object -- the output_p decision should be made by
|
||||
the child of this object. */
|
||||
simple container object -- the output_p decision should be made by
|
||||
the child of this object. */
|
||||
|
||||
if (enc->decoder_data)
|
||||
return MimeDecoderWrite (enc->decoder_data, buffer, size);
|
||||
return MimeDecoderWrite (enc->decoder_data, buffer, size);
|
||||
else
|
||||
return ((MimeEncryptedClass *)obj->clazz)->parse_decoded_buffer (buffer,
|
||||
size,
|
||||
obj);
|
||||
return ((MimeEncryptedClass *)obj->clazz)->parse_decoded_buffer (buffer,
|
||||
size,
|
||||
obj);
|
||||
}
|
||||
|
||||
|
||||
@@ -189,8 +188,8 @@ MimeEncrypted_parse_decoded_buffer (const char *buffer, PRInt32 size, MimeObject
|
||||
{
|
||||
MimeEncrypted *enc = (MimeEncrypted *) obj;
|
||||
return
|
||||
((MimeEncryptedClass *) obj->clazz)->crypto_write (buffer, size,
|
||||
enc->crypto_closure);
|
||||
((MimeEncryptedClass *) obj->clazz)->crypto_write (buffer, size,
|
||||
enc->crypto_closure);
|
||||
}
|
||||
|
||||
|
||||
@@ -205,63 +204,63 @@ MimeEncrypted_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
|
||||
/* (Duplicated from MimeLeaf, see comments in mimecryp.h.)
|
||||
Close off the decoder, to cause it to give up any buffered data that
|
||||
it is still holding.
|
||||
it is still holding.
|
||||
*/
|
||||
if (enc->decoder_data)
|
||||
{
|
||||
int status = MimeDecoderDestroy(enc->decoder_data, PR_FALSE);
|
||||
enc->decoder_data = 0;
|
||||
if (status < 0) return status;
|
||||
}
|
||||
{
|
||||
int status = MimeDecoderDestroy(enc->decoder_data, PR_FALSE);
|
||||
enc->decoder_data = 0;
|
||||
if (status < 0) return status;
|
||||
}
|
||||
|
||||
|
||||
/* If there is still data in the ibuffer, that means that the last
|
||||
*decrypted* line of this part didn't end in a newline; so push it out
|
||||
anyway (this means that the parse_line method will be called with a
|
||||
string with no trailing newline, which isn't the usual case.) */
|
||||
*decrypted* line of this part didn't end in a newline; so push it out
|
||||
anyway (this means that the parse_line method will be called with a
|
||||
string with no trailing newline, which isn't the usual case.) */
|
||||
if (!abort_p &&
|
||||
obj->ibuffer_fp > 0)
|
||||
{
|
||||
int status = MimeHandleDecryptedOutputLine (obj->ibuffer,
|
||||
obj->ibuffer_fp, obj);
|
||||
obj->ibuffer_fp = 0;
|
||||
if (status < 0)
|
||||
{
|
||||
obj->closed_p = PR_TRUE;
|
||||
return status;
|
||||
}
|
||||
}
|
||||
obj->ibuffer_fp > 0)
|
||||
{
|
||||
int status = MimeHandleDecryptedOutputLine (obj->ibuffer,
|
||||
obj->ibuffer_fp, obj);
|
||||
obj->ibuffer_fp = 0;
|
||||
if (status < 0)
|
||||
{
|
||||
obj->closed_p = PR_TRUE;
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Now run the superclass's parse_eof, which (because we've already taken
|
||||
care of ibuffer in a way appropriate for this class, immediately above)
|
||||
will ony set closed_p to true.
|
||||
care of ibuffer in a way appropriate for this class, immediately above)
|
||||
will ony set closed_p to true.
|
||||
*/
|
||||
status = ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_eof (obj, abort_p);
|
||||
if (status < 0) return status;
|
||||
|
||||
|
||||
/* Now close off the underlying crypto module. At this point, the crypto
|
||||
module has all of the input. (DecoderDestroy called parse_decoded_buffer
|
||||
which called crypto_write, with the last of the data.)
|
||||
module has all of the input. (DecoderDestroy called parse_decoded_buffer
|
||||
which called crypto_write, with the last of the data.)
|
||||
*/
|
||||
if (enc->crypto_closure)
|
||||
{
|
||||
status =
|
||||
((MimeEncryptedClass *) obj->clazz)->crypto_eof (enc->crypto_closure,
|
||||
abort_p);
|
||||
if (status < 0 && !abort_p)
|
||||
return status;
|
||||
}
|
||||
{
|
||||
status =
|
||||
((MimeEncryptedClass *) obj->clazz)->crypto_eof (enc->crypto_closure,
|
||||
abort_p);
|
||||
if (status < 0 && !abort_p)
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Now we have the entire child part in the part buffer.
|
||||
We are now able to verify its signature, emit a blurb, and then
|
||||
emit the part.
|
||||
We are now able to verify its signature, emit a blurb, and then
|
||||
emit the part.
|
||||
*/
|
||||
if (abort_p)
|
||||
return 0;
|
||||
return 0;
|
||||
else
|
||||
return MimeEncrypted_emit_buffered_child (obj);
|
||||
return MimeEncrypted_emit_buffered_child (obj);
|
||||
}
|
||||
|
||||
|
||||
@@ -278,33 +277,33 @@ MimeEncrypted_cleanup (MimeObject *obj, PRBool finalizing_p)
|
||||
MimeEncrypted *enc = (MimeEncrypted *) obj;
|
||||
|
||||
if (enc->part_buffer)
|
||||
{
|
||||
MimePartBufferDestroy(enc->part_buffer);
|
||||
enc->part_buffer = 0;
|
||||
}
|
||||
{
|
||||
MimePartBufferDestroy(enc->part_buffer);
|
||||
enc->part_buffer = 0;
|
||||
}
|
||||
|
||||
if (finalizing_p && enc->crypto_closure)
|
||||
{
|
||||
/* Don't free these until this object is really going away -- keep them
|
||||
around for the lifetime of the MIME object, so that we can get at the
|
||||
security info of sub-parts of the currently-displayed message. */
|
||||
((MimeEncryptedClass *) obj->clazz)->crypto_free (enc->crypto_closure);
|
||||
enc->crypto_closure = 0;
|
||||
}
|
||||
{
|
||||
/* Don't free these until this object is really going away -- keep them
|
||||
around for the lifetime of the MIME object, so that we can get at the
|
||||
security info of sub-parts of the currently-displayed message. */
|
||||
((MimeEncryptedClass *) obj->clazz)->crypto_free (enc->crypto_closure);
|
||||
enc->crypto_closure = 0;
|
||||
}
|
||||
|
||||
/* (Duplicated from MimeLeaf, see comments in mimecryp.h.)
|
||||
Free the decoder data, if it's still around. */
|
||||
Free the decoder data, if it's still around. */
|
||||
if (enc->decoder_data)
|
||||
{
|
||||
MimeDecoderDestroy(enc->decoder_data, PR_TRUE);
|
||||
enc->decoder_data = 0;
|
||||
}
|
||||
{
|
||||
MimeDecoderDestroy(enc->decoder_data, PR_TRUE);
|
||||
enc->decoder_data = 0;
|
||||
}
|
||||
|
||||
if (enc->hdrs)
|
||||
{
|
||||
MimeHeaders_free(enc->hdrs);
|
||||
enc->hdrs = 0;
|
||||
}
|
||||
{
|
||||
MimeHeaders_free(enc->hdrs);
|
||||
enc->hdrs = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -318,38 +317,38 @@ MimeEncrypted_finalize (MimeObject *obj)
|
||||
|
||||
static int
|
||||
MimeHandleDecryptedOutput (const char *buf, PRInt32 buf_size,
|
||||
void *output_closure)
|
||||
void *output_closure)
|
||||
{
|
||||
/* This method is invoked by the underlying decryption module.
|
||||
The module is assumed to return a MIME object, and its associated
|
||||
headers. For example, if a text/plain document was encrypted,
|
||||
the encryption module would return the following data:
|
||||
The module is assumed to return a MIME object, and its associated
|
||||
headers. For example, if a text/plain document was encrypted,
|
||||
the encryption module would return the following data:
|
||||
|
||||
Content-Type: text/plain
|
||||
Content-Type: text/plain
|
||||
|
||||
Decrypted text goes here.
|
||||
Decrypted text goes here.
|
||||
|
||||
This function will then extract a header block (up to the first
|
||||
blank line, as usual) and will then handle the included data as
|
||||
appropriate.
|
||||
This function will then extract a header block (up to the first
|
||||
blank line, as usual) and will then handle the included data as
|
||||
appropriate.
|
||||
*/
|
||||
MimeObject *obj = (MimeObject *) output_closure;
|
||||
|
||||
/* Is it truly safe to use ibuffer here? I think so... */
|
||||
return mime_LineBuffer (buf, buf_size,
|
||||
&obj->ibuffer, &obj->ibuffer_size, &obj->ibuffer_fp,
|
||||
PR_TRUE,
|
||||
((int (*PR_CALLBACK) (char *, PRInt32, void *))
|
||||
/* This cast is to turn void into MimeObject */
|
||||
MimeHandleDecryptedOutputLine),
|
||||
obj);
|
||||
&obj->ibuffer, &obj->ibuffer_size, &obj->ibuffer_fp,
|
||||
PR_TRUE,
|
||||
((int (*PR_CALLBACK) (char *, PRInt32, void *))
|
||||
/* This cast is to turn void into MimeObject */
|
||||
MimeHandleDecryptedOutputLine),
|
||||
obj);
|
||||
}
|
||||
|
||||
static int
|
||||
MimeHandleDecryptedOutputLine (char *line, PRInt32 length, MimeObject *obj)
|
||||
{
|
||||
/* Largely the same as MimeMessage_parse_line (the other MIME container
|
||||
type which contains exactly one child.)
|
||||
type which contains exactly one child.)
|
||||
*/
|
||||
MimeEncrypted *enc = (MimeEncrypted *) obj;
|
||||
int status = 0;
|
||||
@@ -357,41 +356,41 @@ MimeHandleDecryptedOutputLine (char *line, PRInt32 length, MimeObject *obj)
|
||||
if (!line || !*line) return -1;
|
||||
|
||||
/* If we're supposed to write this object, but aren't supposed to convert
|
||||
it to HTML, simply pass it through unaltered. */
|
||||
it to HTML, simply pass it through unaltered. */
|
||||
if (obj->output_p &&
|
||||
obj->options &&
|
||||
!obj->options->write_html_p &&
|
||||
obj->options->output_fn)
|
||||
return MimeObject_write(obj, line, length, PR_TRUE);
|
||||
obj->options &&
|
||||
!obj->options->write_html_p &&
|
||||
obj->options->output_fn)
|
||||
return MimeObject_write(obj, line, length, PR_TRUE);
|
||||
|
||||
/* If we already have a child object in the buffer, then we're done parsing
|
||||
headers, and all subsequent lines get passed to the inferior object
|
||||
without further processing by us. (Our parent will stop feeding us
|
||||
lines when this MimeMessage part is out of data.)
|
||||
headers, and all subsequent lines get passed to the inferior object
|
||||
without further processing by us. (Our parent will stop feeding us
|
||||
lines when this MimeMessage part is out of data.)
|
||||
*/
|
||||
if (enc->part_buffer)
|
||||
return MimePartBufferWrite (enc->part_buffer, line, length);
|
||||
return MimePartBufferWrite (enc->part_buffer, line, length);
|
||||
|
||||
/* Otherwise we don't yet have a child object in the buffer, which means
|
||||
we're not done parsing our headers yet.
|
||||
we're not done parsing our headers yet.
|
||||
*/
|
||||
if (!enc->hdrs)
|
||||
{
|
||||
enc->hdrs = MimeHeaders_new();
|
||||
if (!enc->hdrs) return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
{
|
||||
enc->hdrs = MimeHeaders_new();
|
||||
if (!enc->hdrs) return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
status = MimeHeaders_parse_line(line, length, enc->hdrs);
|
||||
if (status < 0) return status;
|
||||
|
||||
/* If this line is blank, we're now done parsing headers, and should
|
||||
examine our content-type to create our "body" part.
|
||||
examine our content-type to create our "body" part.
|
||||
*/
|
||||
if (*line == '\r' || *line == '\n')
|
||||
{
|
||||
status = MimeEncrypted_close_headers(obj);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
{
|
||||
status = MimeEncrypted_close_headers(obj);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -404,7 +403,7 @@ MimeEncrypted_close_headers (MimeObject *obj)
|
||||
if (enc->part_buffer) return -1;
|
||||
enc->part_buffer = MimePartBufferCreate();
|
||||
if (!enc->part_buffer)
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -434,83 +433,83 @@ MimeEncrypted_emit_buffered_child(MimeObject *obj)
|
||||
NS_ASSERTION(enc->crypto_closure, "1.2 <mscott@netscape.com> 01 Nov 2001 17:59");
|
||||
|
||||
/* Emit some HTML saying whether the signature was cool.
|
||||
But don't emit anything if in FO_QUOTE_MESSAGE mode.
|
||||
But don't emit anything if in FO_QUOTE_MESSAGE mode.
|
||||
|
||||
Also, don't emit anything if the enclosed object is itself a signed
|
||||
object -- in the case of an encrypted object which contains a signed
|
||||
object, we only emit the HTML once (since the normal way of encrypting
|
||||
and signing is to nest the signature inside the crypto envelope.)
|
||||
Also, don't emit anything if the enclosed object is itself a signed
|
||||
object -- in the case of an encrypted object which contains a signed
|
||||
object, we only emit the HTML once (since the normal way of encrypting
|
||||
and signing is to nest the signature inside the crypto envelope.)
|
||||
*/
|
||||
if (enc->crypto_closure &&
|
||||
obj->options &&
|
||||
obj->options->headers != MimeHeadersCitation &&
|
||||
obj->options->write_html_p &&
|
||||
obj->options->output_fn)
|
||||
// && !mime_crypto_object_p(enc->hdrs, PR_TRUE)) // XXX fix later XXX //
|
||||
{
|
||||
obj->options &&
|
||||
obj->options->headers != MimeHeadersCitation &&
|
||||
obj->options->write_html_p &&
|
||||
obj->options->output_fn)
|
||||
// && !mime_crypto_object_p(enc->hdrs, PR_TRUE)) // XXX fix later XXX //
|
||||
{
|
||||
char *html;
|
||||
#if 0 // XXX Fix this later XXX //
|
||||
char *html = (((MimeEncryptedClass *) obj->clazz)->crypto_generate_html
|
||||
(enc->crypto_closure));
|
||||
if (!html) return -1; /* MK_OUT_OF_MEMORY? */
|
||||
|
||||
status = MimeObject_write(obj, html, nsCRT::strlen(html), PR_FALSE);
|
||||
PR_FREEIF(html);
|
||||
if (status < 0) return status;
|
||||
char *html = (((MimeEncryptedClass *) obj->clazz)->crypto_generate_html
|
||||
(enc->crypto_closure));
|
||||
if (!html) return -1; /* MK_OUT_OF_MEMORY? */
|
||||
|
||||
status = MimeObject_write(obj, html, strlen(html), PR_FALSE);
|
||||
PR_FREEIF(html);
|
||||
if (status < 0) return status;
|
||||
#endif
|
||||
|
||||
/* Now that we have written out the crypto stamp, the outermost header
|
||||
block is well and truly closed. If this is in fact the outermost
|
||||
message, then run the post_header_html_fn now.
|
||||
*/
|
||||
if (obj->options &&
|
||||
obj->options->state &&
|
||||
obj->options->generate_post_header_html_fn &&
|
||||
!obj->options->state->post_header_html_run_p)
|
||||
{
|
||||
MimeHeaders *outer_headers = nsnull;
|
||||
MimeObject *p;
|
||||
for (p = obj; p->parent; p = p->parent)
|
||||
outer_headers = p->headers;
|
||||
NS_ASSERTION(obj->options->state->first_data_written_p, "1.2 <mscott@netscape.com> 01 Nov 2001 17:59");
|
||||
html = obj->options->generate_post_header_html_fn(NULL,
|
||||
obj->options->html_closure,
|
||||
outer_headers);
|
||||
obj->options->state->post_header_html_run_p = PR_TRUE;
|
||||
if (html)
|
||||
{
|
||||
/* Now that we have written out the crypto stamp, the outermost header
|
||||
block is well and truly closed. If this is in fact the outermost
|
||||
message, then run the post_header_html_fn now.
|
||||
*/
|
||||
if (obj->options &&
|
||||
obj->options->state &&
|
||||
obj->options->generate_post_header_html_fn &&
|
||||
!obj->options->state->post_header_html_run_p)
|
||||
{
|
||||
MimeHeaders *outer_headers = nsnull;
|
||||
MimeObject *p;
|
||||
for (p = obj; p->parent; p = p->parent)
|
||||
outer_headers = p->headers;
|
||||
NS_ASSERTION(obj->options->state->first_data_written_p, "1.2 <mscott@netscape.com> 01 Nov 2001 17:59");
|
||||
html = obj->options->generate_post_header_html_fn(NULL,
|
||||
obj->options->html_closure,
|
||||
outer_headers);
|
||||
obj->options->state->post_header_html_run_p = PR_TRUE;
|
||||
if (html)
|
||||
{
|
||||
status = MimeObject_write(obj, html, strlen(html), PR_FALSE);
|
||||
PR_FREEIF(html);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
PR_FREEIF(html);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (enc->crypto_closure &&
|
||||
obj->options &&
|
||||
obj->options->decrypt_p)
|
||||
{
|
||||
/* Do this just to cause `mime_set_crypto_stamp' to be called, and to
|
||||
cause the various `decode_error' and `verify_error' slots to be set:
|
||||
we don't actually use the returned HTML, because we're not emitting
|
||||
HTML. It's maybe not such a good thing that the determination of
|
||||
whether it was encrypted or not is tied up with generating HTML,
|
||||
but oh well. */
|
||||
char *html = (((MimeEncryptedClass *) obj->clazz)->crypto_generate_html
|
||||
(enc->crypto_closure));
|
||||
PR_FREEIF(html);
|
||||
}
|
||||
obj->options &&
|
||||
obj->options->decrypt_p)
|
||||
{
|
||||
/* Do this just to cause `mime_set_crypto_stamp' to be called, and to
|
||||
cause the various `decode_error' and `verify_error' slots to be set:
|
||||
we don't actually use the returned HTML, because we're not emitting
|
||||
HTML. It's maybe not such a good thing that the determination of
|
||||
whether it was encrypted or not is tied up with generating HTML,
|
||||
but oh well. */
|
||||
char *html = (((MimeEncryptedClass *) obj->clazz)->crypto_generate_html
|
||||
(enc->crypto_closure));
|
||||
PR_FREEIF(html);
|
||||
}
|
||||
|
||||
if (enc->hdrs)
|
||||
ct = MimeHeaders_get (enc->hdrs, HEADER_CONTENT_TYPE, PR_TRUE, PR_FALSE);
|
||||
ct = MimeHeaders_get (enc->hdrs, HEADER_CONTENT_TYPE, PR_TRUE, PR_FALSE);
|
||||
body = mime_create((ct ? ct : TEXT_PLAIN), enc->hdrs, obj->options);
|
||||
|
||||
|
||||
#ifdef MIME_DRAFTS
|
||||
if (obj->options->decompose_file_p) {
|
||||
if (mime_typep (body, (MimeObjectClass*) &mimeMultipartClass) )
|
||||
obj->options->is_multipart_msg = PR_TRUE;
|
||||
else if (obj->options->decompose_file_init_fn)
|
||||
obj->options->decompose_file_init_fn(obj->options->stream_closure,
|
||||
enc->hdrs);
|
||||
if (mime_typep (body, (MimeObjectClass*) &mimeMultipartClass) )
|
||||
obj->options->is_multipart_msg = PR_TRUE;
|
||||
else if (obj->options->decompose_file_init_fn)
|
||||
obj->options->decompose_file_init_fn(obj->options->stream_closure,
|
||||
enc->hdrs);
|
||||
}
|
||||
#endif /* MIME_DRAFTS */
|
||||
|
||||
@@ -519,55 +518,55 @@ MimeEncrypted_emit_buffered_child(MimeObject *obj)
|
||||
if (!body) return MIME_OUT_OF_MEMORY;
|
||||
status = ((MimeContainerClass *) obj->clazz)->add_child (obj, body);
|
||||
if (status < 0)
|
||||
{
|
||||
mime_free(body);
|
||||
return status;
|
||||
}
|
||||
{
|
||||
mime_free(body);
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Now that we've added this new object to our list of children,
|
||||
start its parser going. */
|
||||
start its parser going. */
|
||||
status = body->clazz->parse_begin(body);
|
||||
if (status < 0) return status;
|
||||
|
||||
/* If this object (or the parent) is being output, then by definition
|
||||
the child is as well. (This is only necessary because this is such
|
||||
a funny sort of container...)
|
||||
the child is as well. (This is only necessary because this is such
|
||||
a funny sort of container...)
|
||||
*/
|
||||
if (!body->output_p &&
|
||||
(obj->output_p ||
|
||||
(obj->parent && obj->parent->output_p)))
|
||||
body->output_p = PR_TRUE;
|
||||
(obj->output_p ||
|
||||
(obj->parent && obj->parent->output_p)))
|
||||
body->output_p = PR_TRUE;
|
||||
|
||||
/* If the body is being written raw (not as HTML) then make sure to
|
||||
write its headers as well. */
|
||||
write its headers as well. */
|
||||
if (body->output_p && obj->output_p && !obj->options->write_html_p)
|
||||
{
|
||||
status = MimeObject_write(body, "", 0, PR_FALSE); /* initialize */
|
||||
if (status < 0) return status;
|
||||
status = MimeHeaders_write_raw_headers(body->headers, obj->options,
|
||||
PR_FALSE);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
{
|
||||
status = MimeObject_write(body, "", 0, PR_FALSE); /* initialize */
|
||||
if (status < 0) return status;
|
||||
status = MimeHeaders_write_raw_headers(body->headers, obj->options,
|
||||
PR_FALSE);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
|
||||
if (enc->part_buffer) /* part_buffer is 0 for 0-length encrypted data. */
|
||||
|
||||
#ifdef MIME_DRAFTS
|
||||
if (obj->options->decompose_file_p && !obj->options->is_multipart_msg)
|
||||
status = MimePartBufferRead(enc->part_buffer,
|
||||
/* The (nsresult (*) ...) cast is to turn the `void'
|
||||
argument into `MimeObject'. */
|
||||
((nsresult (*) (const char *, PRInt32, void *))
|
||||
obj->options->decompose_file_output_fn),
|
||||
obj->options->stream_closure);
|
||||
status = MimePartBufferRead(enc->part_buffer,
|
||||
/* The (nsresult (*) ...) cast is to turn the `void'
|
||||
argument into `MimeObject'. */
|
||||
((nsresult (*) (const char *, PRInt32, void *))
|
||||
obj->options->decompose_file_output_fn),
|
||||
obj->options->stream_closure);
|
||||
else
|
||||
#endif /* MIME_DRAFTS */
|
||||
|
||||
status = MimePartBufferRead(enc->part_buffer,
|
||||
/* The (nsresult (*) ...) cast is to turn the `void'
|
||||
argument into `MimeObject'. */
|
||||
((nsresult (*) (const char *, PRInt32, void *))
|
||||
body->clazz->parse_buffer),
|
||||
body);
|
||||
status = MimePartBufferRead(enc->part_buffer,
|
||||
/* The (nsresult (*) ...) cast is to turn the `void'
|
||||
argument into `MimeObject'. */
|
||||
((nsresult (*) (const char *, PRInt32, void *))
|
||||
body->clazz->parse_buffer),
|
||||
body);
|
||||
if (status < 0) return status;
|
||||
|
||||
/* The child has been fully processed. Close it off.
|
||||
@@ -580,7 +579,7 @@ MimeEncrypted_emit_buffered_child(MimeObject *obj)
|
||||
|
||||
#ifdef MIME_DRAFTS
|
||||
if (obj->options->decompose_file_p && !obj->options->is_multipart_msg)
|
||||
obj->options->decompose_file_close_fn(obj->options->stream_closure);
|
||||
obj->options->decompose_file_close_fn(obj->options->stream_closure);
|
||||
#endif /* MIME_DRAFTS */
|
||||
|
||||
/* Put out a separator after every encrypted object. */
|
||||
|
||||
@@ -59,7 +59,6 @@
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "msgCore.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsIMsgSend.h"
|
||||
#include "nsMimeStringResources.h"
|
||||
@@ -294,7 +293,7 @@ CreateCompositionFields(const char *from,
|
||||
NS_ENSURE_TRUE(cFields, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// Now set all of the passed in stuff...
|
||||
cFields->SetCharacterSet(!nsCRT::strcasecmp("us-ascii", charset) ? "ISO-8859-1" : charset);
|
||||
cFields->SetCharacterSet(!PL_strcasecmp("us-ascii", charset) ? "ISO-8859-1" : charset);
|
||||
|
||||
char *val;
|
||||
|
||||
@@ -543,7 +542,7 @@ mime_draft_process_attachments(mime_draft_data *mdd)
|
||||
{
|
||||
if (tmpFile->type)
|
||||
{
|
||||
if (nsCRT::strcasecmp ( tmpFile->type, "text/x-vcard") == 0)
|
||||
if (PL_strcasecmp ( tmpFile->type, "text/x-vcard") == 0)
|
||||
NS_MsgSACopy (&(tmp->real_name), tmpFile->description);
|
||||
}
|
||||
|
||||
@@ -783,18 +782,18 @@ mime_insert_all_headers(char **body,
|
||||
|
||||
/* Back up over whitespace before the colon. */
|
||||
ocolon = colon;
|
||||
for (; colon > head && nsCRT::IsAsciiSpace(colon[-1]); colon--)
|
||||
for (; colon > head && IS_SPACE(colon[-1]); colon--)
|
||||
;
|
||||
|
||||
contents = ocolon + 1;
|
||||
}
|
||||
|
||||
/* Skip over whitespace after colon. */
|
||||
while (contents <= end && nsCRT::IsAsciiSpace(*contents))
|
||||
while (contents <= end && IS_SPACE(*contents))
|
||||
contents++;
|
||||
|
||||
/* Take off trailing whitespace... */
|
||||
while (end > contents && nsCRT::IsAsciiSpace(end[-1]))
|
||||
while (end > contents && IS_SPACE(end[-1]))
|
||||
end--;
|
||||
|
||||
name = (char *)PR_MALLOC(colon - head + 1);
|
||||
@@ -815,15 +814,15 @@ mime_insert_all_headers(char **body,
|
||||
/* Do not reveal bcc recipients when forwarding a message!
|
||||
See http://bugzilla.mozilla.org/show_bug.cgi?id=41150
|
||||
*/
|
||||
if (nsCRT::strcasecmp(name, "bcc") != 0)
|
||||
if (PL_strcasecmp(name, "bcc") != 0)
|
||||
{
|
||||
if (htmlEdit)
|
||||
mime_fix_up_html_address(&c2);
|
||||
|
||||
if (!nsCRT::strcasecmp(name, "resent-from") || !nsCRT::strcasecmp(name, "from") ||
|
||||
!nsCRT::strcasecmp(name, "resent-to") || !nsCRT::strcasecmp(name, "to") ||
|
||||
!nsCRT::strcasecmp(name, "resent-cc") || !nsCRT::strcasecmp(name, "cc") ||
|
||||
!nsCRT::strcasecmp(name, "reply-to"))
|
||||
if (!PL_strcasecmp(name, "resent-from") || !PL_strcasecmp(name, "from") ||
|
||||
!PL_strcasecmp(name, "resent-to") || !PL_strcasecmp(name, "to") ||
|
||||
!PL_strcasecmp(name, "resent-cc") || !PL_strcasecmp(name, "cc") ||
|
||||
!PL_strcasecmp(name, "reply-to"))
|
||||
UnquoteMimeAddress(parser, &c2);
|
||||
|
||||
mime_intl_insert_message_header_1(&newBody, &c2, name, name, mailcharset, htmlEdit);
|
||||
@@ -1273,7 +1272,7 @@ mime_parse_stream_complete (nsMIMESession *stream)
|
||||
if ((!mdd->mailcharset || charsetOverride) && mdd->options->default_charset)
|
||||
{
|
||||
PR_Free(mdd->mailcharset);
|
||||
mdd->mailcharset = nsCRT::strdup(mdd->options->default_charset);
|
||||
mdd->mailcharset = strdup(mdd->options->default_charset);
|
||||
}
|
||||
|
||||
// mscott: aren't we leaking a bunch of strings here like the charset strings and such?
|
||||
@@ -1360,12 +1359,12 @@ mime_parse_stream_complete (nsMIMESession *stream)
|
||||
{
|
||||
char *parm = 0;
|
||||
parm = MimeHeaders_get_parameter(draftInfo, "vcard", NULL, NULL);
|
||||
fields->SetAttachVCard(parm && !nsCRT::strcmp(parm, "1"));
|
||||
fields->SetAttachVCard(parm && !strcmp(parm, "1"));
|
||||
|
||||
fields->SetMessageId(id); // keep same message id for editing template.
|
||||
PR_FREEIF(parm);
|
||||
parm = MimeHeaders_get_parameter(draftInfo, "receipt", NULL, NULL);
|
||||
if (parm && !nsCRT::strcmp(parm, "0"))
|
||||
if (parm && !strcmp(parm, "0"))
|
||||
fields->SetReturnReceipt(PR_FALSE);
|
||||
else
|
||||
{
|
||||
@@ -1380,7 +1379,7 @@ mime_parse_stream_complete (nsMIMESession *stream)
|
||||
}
|
||||
PR_FREEIF(parm);
|
||||
parm = MimeHeaders_get_parameter(draftInfo, "uuencode", NULL, NULL);
|
||||
fields->SetUuEncodeAttachments(parm && !nsCRT::strcmp(parm, "1"));
|
||||
fields->SetUuEncodeAttachments(parm && !strcmp(parm, "1"));
|
||||
PR_FREEIF(parm);
|
||||
parm = MimeHeaders_get_parameter(draftInfo, "html", NULL, NULL);
|
||||
if (parm)
|
||||
@@ -1748,7 +1747,7 @@ mime_decompose_file_init_fn ( void *stream_closure, MimeHeaders *headers )
|
||||
// if we've been told to use an override charset then do so....otherwise use the charset
|
||||
// inside the message header...
|
||||
if (mdd->options && mdd->options->override_charset)
|
||||
mdd->mailcharset = nsCRT::strdup(mdd->options->default_charset);
|
||||
mdd->mailcharset = strdup(mdd->options->default_charset);
|
||||
else
|
||||
{
|
||||
char *contentType = NULL;
|
||||
@@ -1807,9 +1806,9 @@ mime_decompose_file_init_fn ( void *stream_closure, MimeHeaders *headers )
|
||||
contLoc = MimeHeaders_get( headers, HEADER_CONTENT_BASE, PR_FALSE, PR_FALSE );
|
||||
|
||||
if ( (!contLoc) && (newAttachment->real_name) )
|
||||
workURLSpec = nsCRT::strdup(newAttachment->real_name);
|
||||
workURLSpec = strdup(newAttachment->real_name);
|
||||
if ( (contLoc) && (!workURLSpec) )
|
||||
workURLSpec = nsCRT::strdup(contLoc);
|
||||
workURLSpec = strdup(contLoc);
|
||||
|
||||
PR_FREEIF(contLoc);
|
||||
|
||||
@@ -1843,7 +1842,7 @@ mime_decompose_file_init_fn ( void *stream_closure, MimeHeaders *headers )
|
||||
// If we came up empty for description or the orig URL, we should do something about it.
|
||||
//
|
||||
if ( ( (!newAttachment->description) || (!*newAttachment->description) ) && (workURLSpec) )
|
||||
newAttachment->description = nsCRT::strdup(workURLSpec);
|
||||
newAttachment->description = strdup(workURLSpec);
|
||||
|
||||
nsCOMPtr <nsIFile> tmpFile = nsnull;
|
||||
{
|
||||
@@ -1916,9 +1915,9 @@ mime_decompose_file_init_fn ( void *stream_closure, MimeHeaders *headers )
|
||||
//
|
||||
if (!newAttachment->encoding)
|
||||
;
|
||||
else if (!nsCRT::strcasecmp(newAttachment->encoding, ENCODING_BASE64))
|
||||
else if (!PL_strcasecmp(newAttachment->encoding, ENCODING_BASE64))
|
||||
fn = &MimeB64DecoderInit;
|
||||
else if (!nsCRT::strcasecmp(newAttachment->encoding, ENCODING_QUOTED_PRINTABLE))
|
||||
else if (!PL_strcasecmp(newAttachment->encoding, ENCODING_QUOTED_PRINTABLE))
|
||||
{
|
||||
mdd->decoder_data = MimeQPDecoderInit (/* The (nsresult (*) ...) cast is to turn the `void' argument into `MimeObject'. */
|
||||
((nsresult (*) (const char *, PRInt32, void *))
|
||||
@@ -1926,12 +1925,12 @@ mime_decompose_file_init_fn ( void *stream_closure, MimeHeaders *headers )
|
||||
if (!mdd->decoder_data)
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
else if (!nsCRT::strcasecmp(newAttachment->encoding, ENCODING_UUENCODE) ||
|
||||
!nsCRT::strcasecmp(newAttachment->encoding, ENCODING_UUENCODE2) ||
|
||||
!nsCRT::strcasecmp(newAttachment->encoding, ENCODING_UUENCODE3) ||
|
||||
!nsCRT::strcasecmp(newAttachment->encoding, ENCODING_UUENCODE4))
|
||||
else if (!PL_strcasecmp(newAttachment->encoding, ENCODING_UUENCODE) ||
|
||||
!PL_strcasecmp(newAttachment->encoding, ENCODING_UUENCODE2) ||
|
||||
!PL_strcasecmp(newAttachment->encoding, ENCODING_UUENCODE3) ||
|
||||
!PL_strcasecmp(newAttachment->encoding, ENCODING_UUENCODE4))
|
||||
fn = &MimeUUDecoderInit;
|
||||
else if (!nsCRT::strcasecmp(newAttachment->encoding, ENCODING_YENCODE))
|
||||
else if (!PL_strcasecmp(newAttachment->encoding, ENCODING_YENCODE))
|
||||
fn = &MimeYDecoderInit;
|
||||
|
||||
if (fn)
|
||||
@@ -2058,7 +2057,7 @@ mime_bridge_create_draft_stream(
|
||||
if (!mdd->options)
|
||||
goto FAIL;
|
||||
|
||||
mdd->options->url = nsCRT::strdup(mdd->url_name);
|
||||
mdd->options->url = strdup(mdd->url_name);
|
||||
mdd->options->format_out = format_out; // output format
|
||||
mdd->options->decompose_file_p = PR_TRUE; /* new field in MimeDisplayOptions */
|
||||
mdd->options->stream_closure = mdd;
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#include "nsIURL.h"
|
||||
#include "mimeebod.h"
|
||||
#include "prmem.h"
|
||||
#include "nsCRT.h"
|
||||
#include "plstr.h"
|
||||
#include "prlog.h"
|
||||
#include "prio.h"
|
||||
@@ -50,7 +49,7 @@
|
||||
|
||||
#define MIME_SUPERCLASS mimeObjectClass
|
||||
MimeDefClass(MimeExternalBody, MimeExternalBodyClass,
|
||||
mimeExternalBodyClass, &MIME_SUPERCLASS);
|
||||
mimeExternalBodyClass, &MIME_SUPERCLASS);
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
extern MimeObjectClass mimeMultipartAppleDoubleClass;
|
||||
@@ -61,7 +60,7 @@ static void MimeExternalBody_finalize (MimeObject *);
|
||||
static int MimeExternalBody_parse_line (const char *, PRInt32, MimeObject *);
|
||||
static int MimeExternalBody_parse_eof (MimeObject *, PRBool);
|
||||
static PRBool MimeExternalBody_displayable_inline_p (MimeObjectClass *clazz,
|
||||
MimeHeaders *hdrs);
|
||||
MimeHeaders *hdrs);
|
||||
|
||||
#if 0
|
||||
#if defined(DEBUG) && defined(XP_UNIX)
|
||||
@@ -102,10 +101,10 @@ MimeExternalBody_finalize (MimeObject *object)
|
||||
{
|
||||
MimeExternalBody *bod = (MimeExternalBody *) object;
|
||||
if (bod->hdrs)
|
||||
{
|
||||
MimeHeaders_free(bod->hdrs);
|
||||
bod->hdrs = 0;
|
||||
}
|
||||
{
|
||||
MimeHeaders_free(bod->hdrs);
|
||||
bod->hdrs = 0;
|
||||
}
|
||||
PR_FREEIF(bod->body);
|
||||
|
||||
((MimeObjectClass*)&MIME_SUPERCLASS)->finalize(object);
|
||||
@@ -123,46 +122,46 @@ MimeExternalBody_parse_line (const char *line, PRInt32 length, MimeObject *obj)
|
||||
if (!obj->output_p) return 0;
|
||||
|
||||
/* If we're supposed to write this object, but aren't supposed to convert
|
||||
it to HTML, simply pass it through unaltered. */
|
||||
it to HTML, simply pass it through unaltered. */
|
||||
if (obj->options &&
|
||||
!obj->options->write_html_p &&
|
||||
obj->options->output_fn)
|
||||
return MimeObject_write(obj, line, length, PR_TRUE);
|
||||
!obj->options->write_html_p &&
|
||||
obj->options->output_fn)
|
||||
return MimeObject_write(obj, line, length, PR_TRUE);
|
||||
|
||||
|
||||
/* If we already have a `body' then we're done parsing headers, and all
|
||||
subsequent lines get tacked onto the body. */
|
||||
subsequent lines get tacked onto the body. */
|
||||
if (bod->body)
|
||||
{
|
||||
int L = strlen(bod->body);
|
||||
char *new_str = (char *)PR_Realloc(bod->body, L + length + 1);
|
||||
if (!new_str) return MIME_OUT_OF_MEMORY;
|
||||
bod->body = new_str;
|
||||
memcpy(bod->body + L, line, length);
|
||||
bod->body[L + length] = 0;
|
||||
return 0;
|
||||
}
|
||||
{
|
||||
int L = strlen(bod->body);
|
||||
char *new_str = (char *)PR_Realloc(bod->body, L + length + 1);
|
||||
if (!new_str) return MIME_OUT_OF_MEMORY;
|
||||
bod->body = new_str;
|
||||
memcpy(bod->body + L, line, length);
|
||||
bod->body[L + length] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Otherwise we don't yet have a body, which means we're not done parsing
|
||||
our headers.
|
||||
our headers.
|
||||
*/
|
||||
if (!bod->hdrs)
|
||||
{
|
||||
bod->hdrs = MimeHeaders_new();
|
||||
if (!bod->hdrs) return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
{
|
||||
bod->hdrs = MimeHeaders_new();
|
||||
if (!bod->hdrs) return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
status = MimeHeaders_parse_line(line, length, bod->hdrs);
|
||||
if (status < 0) return status;
|
||||
|
||||
/* If this line is blank, we're now done parsing headers, and should
|
||||
create a dummy body to show that. Gag.
|
||||
create a dummy body to show that. Gag.
|
||||
*/
|
||||
if (*line == '\r' || *line == '\n')
|
||||
{
|
||||
bod->body = nsCRT::strdup("");
|
||||
if (!bod->body) return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
{
|
||||
bod->body = strdup("");
|
||||
if (!bod->body) return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -170,17 +169,17 @@ MimeExternalBody_parse_line (const char *line, PRInt32 length, MimeObject *obj)
|
||||
|
||||
char *
|
||||
MimeExternalBody_make_url(const char *ct,
|
||||
const char *at, const char *lexp, const char *size,
|
||||
const char *perm, const char *dir, const char *mode,
|
||||
const char *name, const char *url, const char *site,
|
||||
const char *svr, const char *subj, const char *body)
|
||||
const char *at, const char *lexp, const char *size,
|
||||
const char *perm, const char *dir, const char *mode,
|
||||
const char *name, const char *url, const char *site,
|
||||
const char *svr, const char *subj, const char *body)
|
||||
{
|
||||
char *s;
|
||||
if (!at)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (!nsCRT::strcasecmp(at, "ftp") || !nsCRT::strcasecmp(at, "anon-ftp"))
|
||||
else if (!PL_strcasecmp(at, "ftp") || !PL_strcasecmp(at, "anon-ftp"))
|
||||
{
|
||||
if (!site || !name)
|
||||
return 0;
|
||||
@@ -196,14 +195,14 @@ MimeExternalBody_make_url(const char *ct,
|
||||
PL_strcat(s, name);
|
||||
return s;
|
||||
}
|
||||
else if (!nsCRT::strcasecmp(at, "local-file") || !nsCRT::strcasecmp(at, "afs"))
|
||||
else if (!PL_strcasecmp(at, "local-file") || !PL_strcasecmp(at, "afs"))
|
||||
{
|
||||
char *s2;
|
||||
if (!name)
|
||||
return 0;
|
||||
|
||||
|
||||
#ifdef XP_UNIX
|
||||
if (!nsCRT::strcasecmp(at, "afs")) /* only if there is a /afs/ directory */
|
||||
if (!PL_strcasecmp(at, "afs")) /* only if there is a /afs/ directory */
|
||||
{
|
||||
nsCOMPtr <nsILocalFile> fs = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
|
||||
PRBool exists = PR_FALSE;
|
||||
@@ -216,7 +215,7 @@ MimeExternalBody_make_url(const char *ct,
|
||||
return 0;
|
||||
}
|
||||
#else /* !XP_UNIX */
|
||||
return 0; /* never, if not Unix. */
|
||||
return 0; /* never, if not Unix. */
|
||||
#endif /* !XP_UNIX */
|
||||
|
||||
s = (char *) PR_MALLOC(strlen(name)*3 + 20);
|
||||
@@ -227,11 +226,11 @@ s2 = nsEscape(name, url_Path);
|
||||
if (s2)
|
||||
{
|
||||
PL_strcat(s, s2);
|
||||
nsCRT::free(s2);
|
||||
NS_Free(s2);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
else if (!nsCRT::strcasecmp(at, "mail-server"))
|
||||
}
|
||||
else if (!PL_strcasecmp(at, "mail-server"))
|
||||
{
|
||||
char *s2;
|
||||
if (!svr)
|
||||
@@ -241,40 +240,40 @@ else if (!nsCRT::strcasecmp(at, "mail-server"))
|
||||
(body ? strlen(body)*4 : 0) + 20);
|
||||
if (!s) return 0;
|
||||
PL_strcpy(s, "mailto:");
|
||||
|
||||
|
||||
s2 = nsEscape(svr, url_XAlphas);
|
||||
if (s2)
|
||||
{
|
||||
PL_strcat(s, s2);
|
||||
nsCRT::free(s2);
|
||||
NS_Free(s2);
|
||||
}
|
||||
|
||||
|
||||
if (subj)
|
||||
{
|
||||
s2 = nsEscape(subj, url_XAlphas);
|
||||
PL_strcat(s, "?subject=");
|
||||
if (s2)
|
||||
{
|
||||
{
|
||||
s2 = nsEscape(subj, url_XAlphas);
|
||||
PL_strcat(s, "?subject=");
|
||||
if (s2)
|
||||
{
|
||||
PL_strcat(s, s2);
|
||||
nsCRT::free(s2);
|
||||
}
|
||||
}
|
||||
NS_Free(s2);
|
||||
}
|
||||
}
|
||||
if (body)
|
||||
{
|
||||
s2 = nsEscape(body, url_XAlphas);
|
||||
PL_strcat(s, (subj ? "&body=" : "?body="));
|
||||
if (s2)
|
||||
{
|
||||
{
|
||||
s2 = nsEscape(body, url_XAlphas);
|
||||
PL_strcat(s, (subj ? "&body=" : "?body="));
|
||||
if (s2)
|
||||
{
|
||||
PL_strcat(s, s2);
|
||||
nsCRT::free(s2);
|
||||
}
|
||||
}
|
||||
NS_Free(s2);
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
else if (!nsCRT::strcasecmp(at, "url")) /* RFC 2017 */
|
||||
else if (!PL_strcasecmp(at, "url")) /* RFC 2017 */
|
||||
{
|
||||
if (url)
|
||||
return nsCRT::strdup(url); /* it's already quoted and everything */
|
||||
return strdup(url); /* it's already quoted and everything */
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@@ -287,19 +286,19 @@ MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
{
|
||||
int status = 0;
|
||||
MimeExternalBody *bod = (MimeExternalBody *) obj;
|
||||
|
||||
|
||||
if (obj->closed_p) return 0;
|
||||
|
||||
|
||||
/* Run parent method first, to flush out any buffered data. */
|
||||
status = ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_eof(obj, abort_p);
|
||||
if (status < 0) return status;
|
||||
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
if (obj->parent && mime_typep(obj->parent,
|
||||
if (obj->parent && mime_typep(obj->parent,
|
||||
(MimeObjectClass*) &mimeMultipartAppleDoubleClass))
|
||||
goto done;
|
||||
#endif /* XP_MACOSX */
|
||||
|
||||
|
||||
if (!abort_p &&
|
||||
obj->output_p &&
|
||||
obj->options &&
|
||||
@@ -307,16 +306,16 @@ MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
{
|
||||
PRBool all_headers_p = obj->options->headers == MimeHeadersAll;
|
||||
MimeDisplayOptions *newopt = obj->options; /* copy it */
|
||||
|
||||
|
||||
char *ct = MimeHeaders_get(obj->headers, HEADER_CONTENT_TYPE,
|
||||
PR_FALSE, PR_FALSE);
|
||||
char *at, *lexp, *size, *perm;
|
||||
char *url, *dir, *mode, *name, *site, *svr, *subj;
|
||||
char *h = 0, *lname = 0, *lurl = 0, *body = 0;
|
||||
MimeHeaders *hdrs = 0;
|
||||
|
||||
|
||||
if (!ct) return MIME_OUT_OF_MEMORY;
|
||||
|
||||
|
||||
at = MimeHeaders_get_parameter(ct, "access-type", NULL, NULL);
|
||||
lexp = MimeHeaders_get_parameter(ct, "expiration", NULL, NULL);
|
||||
size = MimeHeaders_get_parameter(ct, "size", NULL, NULL);
|
||||
@@ -329,11 +328,11 @@ MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
subj = MimeHeaders_get_parameter(ct, "subject", NULL, NULL);
|
||||
url = MimeHeaders_get_parameter(ct, "url", NULL, NULL);
|
||||
PR_FREEIF(ct);
|
||||
|
||||
|
||||
/* the *internal* content-type */
|
||||
ct = MimeHeaders_get(bod->hdrs, HEADER_CONTENT_TYPE,
|
||||
PR_TRUE, PR_FALSE);
|
||||
|
||||
|
||||
h = (char *) PR_MALLOC((at ? strlen(at) : 0) +
|
||||
(lexp ? strlen(lexp) : 0) +
|
||||
(size ? strlen(size) : 0) +
|
||||
@@ -351,7 +350,7 @@ MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
status = MIME_OUT_OF_MEMORY;
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
|
||||
/* If there's a URL parameter, remove all whitespace from it.
|
||||
(The URL parameter to one of these headers is stored with
|
||||
lines broken every 40 characters or less; it's assumed that
|
||||
@@ -362,18 +361,18 @@ MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
{
|
||||
char *in, *out;
|
||||
for (in = url, out = url; *in; in++)
|
||||
if (!nsCRT::IsAsciiSpace(*in))
|
||||
if (!IS_SPACE(*in))
|
||||
*out++ = *in;
|
||||
*out = 0;
|
||||
}
|
||||
|
||||
|
||||
hdrs = MimeHeaders_new();
|
||||
if (!hdrs)
|
||||
{
|
||||
status = MIME_OUT_OF_MEMORY;
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
|
||||
# define FROB(STR,VAR) \
|
||||
if (VAR) \
|
||||
{ \
|
||||
@@ -383,23 +382,23 @@ MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
status = MimeHeaders_parse_line(h, strlen(h), hdrs); \
|
||||
if (status < 0) goto FAIL; \
|
||||
}
|
||||
FROB("Access-Type", at);
|
||||
FROB("URL", url);
|
||||
FROB("Site", site);
|
||||
FROB("Server", svr);
|
||||
FROB("Directory", dir);
|
||||
FROB("Name", name);
|
||||
FROB("Type", ct);
|
||||
FROB("Size", size);
|
||||
FROB("Mode", mode);
|
||||
FROB("Permission", perm);
|
||||
FROB("Expiration", lexp);
|
||||
FROB("Subject", subj);
|
||||
FROB("Access-Type", at);
|
||||
FROB("URL", url);
|
||||
FROB("Site", site);
|
||||
FROB("Server", svr);
|
||||
FROB("Directory", dir);
|
||||
FROB("Name", name);
|
||||
FROB("Type", ct);
|
||||
FROB("Size", size);
|
||||
FROB("Mode", mode);
|
||||
FROB("Permission", perm);
|
||||
FROB("Expiration", lexp);
|
||||
FROB("Subject", subj);
|
||||
# undef FROB
|
||||
PL_strcpy(h, MSG_LINEBREAK);
|
||||
status = MimeHeaders_parse_line(h, strlen(h), hdrs);
|
||||
if (status < 0) goto FAIL;
|
||||
|
||||
|
||||
lurl = MimeExternalBody_make_url(ct, at, lexp, size, perm, dir, mode,
|
||||
name, url, site, svr, subj, bod->body);
|
||||
if (lurl)
|
||||
@@ -411,20 +410,20 @@ MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
lname = MimeGetStringByID(MIME_MSG_DOCUMENT_INFO);
|
||||
all_headers_p = PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
all_headers_p = PR_TRUE; /* #### just do this all the time? */
|
||||
|
||||
|
||||
if (bod->body && all_headers_p)
|
||||
{
|
||||
char *s = bod->body;
|
||||
while (nsCRT::IsAsciiSpace(*s)) s++;
|
||||
while (IS_SPACE(*s)) s++;
|
||||
if (*s)
|
||||
{
|
||||
char *s2;
|
||||
const char *pre = "<P><PRE>";
|
||||
const char *suf = "</PRE>";
|
||||
PRInt32 i;
|
||||
for(i = strlen(s)-1; i >= 0 && nsCRT::IsAsciiSpace(s[i]); i--)
|
||||
for(i = strlen(s)-1; i >= 0 && IS_SPACE(s[i]); i--)
|
||||
s[i] = 0;
|
||||
s2 = nsEscapeHTML(s);
|
||||
if (!s2) goto FAIL;
|
||||
@@ -432,7 +431,7 @@ MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
strlen(suf) + 1);
|
||||
if (!body)
|
||||
{
|
||||
nsCRT::free(s2);
|
||||
NS_Free(s2);
|
||||
goto FAIL;
|
||||
}
|
||||
PL_strcpy(body, pre);
|
||||
@@ -440,10 +439,10 @@ MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
PL_strcat(body, suf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
newopt->fancy_headers_p = PR_TRUE;
|
||||
newopt->headers = (all_headers_p ? MimeHeadersAll : MimeHeadersSome);
|
||||
|
||||
|
||||
FAIL:
|
||||
if (hdrs)
|
||||
MimeHeaders_free(hdrs);
|
||||
@@ -464,11 +463,11 @@ FAIL:
|
||||
PR_FREEIF(svr);
|
||||
PR_FREEIF(subj);
|
||||
}
|
||||
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
done:
|
||||
#endif
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -483,24 +482,24 @@ MimeExternalBody_debug_print (MimeObject *obj, PRFileDesc *stream, PRInt32 depth
|
||||
char *addr = mime_part_address(obj);
|
||||
|
||||
if (obj->headers)
|
||||
ct = MimeHeaders_get (obj->headers, HEADER_CONTENT_TYPE, PR_FALSE, PR_FALSE);
|
||||
ct = MimeHeaders_get (obj->headers, HEADER_CONTENT_TYPE, PR_FALSE, PR_FALSE);
|
||||
if (bod->hdrs)
|
||||
ct2 = MimeHeaders_get (bod->hdrs, HEADER_CONTENT_TYPE, PR_FALSE, PR_FALSE);
|
||||
ct2 = MimeHeaders_get (bod->hdrs, HEADER_CONTENT_TYPE, PR_FALSE, PR_FALSE);
|
||||
|
||||
for (i=0; i < depth; i++)
|
||||
PR_Write(stream, " ", 2);
|
||||
PR_Write(stream, " ", 2);
|
||||
/***
|
||||
fprintf(stream,
|
||||
"<%s %s\n"
|
||||
"\tcontent-type: %s\n"
|
||||
"\tcontent-type: %s\n"
|
||||
"\tBody:%s\n\t0x%08X>\n\n",
|
||||
obj->clazz->class_name,
|
||||
addr ? addr : "???",
|
||||
ct ? ct : "<none>",
|
||||
ct2 ? ct2 : "<none>",
|
||||
bod->body ? bod->body : "<none>",
|
||||
(PRUint32) obj);
|
||||
"<%s %s\n"
|
||||
"\tcontent-type: %s\n"
|
||||
"\tcontent-type: %s\n"
|
||||
"\tBody:%s\n\t0x%08X>\n\n",
|
||||
obj->clazz->class_name,
|
||||
addr ? addr : "???",
|
||||
ct ? ct : "<none>",
|
||||
ct2 ? ct2 : "<none>",
|
||||
bod->body ? bod->body : "<none>",
|
||||
(PRUint32) obj);
|
||||
***/
|
||||
PR_FREEIF(addr);
|
||||
PR_FREEIF(ct);
|
||||
@@ -512,22 +511,22 @@ MimeExternalBody_debug_print (MimeObject *obj, PRFileDesc *stream, PRInt32 depth
|
||||
|
||||
static PRBool
|
||||
MimeExternalBody_displayable_inline_p (MimeObjectClass *clazz,
|
||||
MimeHeaders *hdrs)
|
||||
MimeHeaders *hdrs)
|
||||
{
|
||||
char *ct = MimeHeaders_get (hdrs, HEADER_CONTENT_TYPE, PR_FALSE, PR_FALSE);
|
||||
char *at = MimeHeaders_get_parameter(ct, "access-type", NULL, NULL);
|
||||
PRBool inline_p = PR_FALSE;
|
||||
|
||||
if (!at)
|
||||
;
|
||||
else if (!nsCRT::strcasecmp(at, "ftp") ||
|
||||
!nsCRT::strcasecmp(at, "anon-ftp") ||
|
||||
!nsCRT::strcasecmp(at, "local-file") ||
|
||||
!nsCRT::strcasecmp(at, "mail-server") ||
|
||||
!nsCRT::strcasecmp(at, "url"))
|
||||
inline_p = PR_TRUE;
|
||||
;
|
||||
else if (!PL_strcasecmp(at, "ftp") ||
|
||||
!PL_strcasecmp(at, "anon-ftp") ||
|
||||
!PL_strcasecmp(at, "local-file") ||
|
||||
!PL_strcasecmp(at, "mail-server") ||
|
||||
!PL_strcasecmp(at, "url"))
|
||||
inline_p = PR_TRUE;
|
||||
#ifdef XP_UNIX
|
||||
else if (!nsCRT::strcasecmp(at, "afs")) /* only if there is a /afs/ directory */
|
||||
else if (!PL_strcasecmp(at, "afs")) /* only if there is a /afs/ directory */
|
||||
{
|
||||
nsCOMPtr <nsILocalFile> fs = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
|
||||
PRBool exists = PR_FALSE;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -42,14 +42,13 @@
|
||||
#include "prlog.h"
|
||||
#include "nsMimeStringResources.h"
|
||||
#include "mimemoz2.h"
|
||||
#include "nsCRT.h"
|
||||
#include "mimemapl.h"
|
||||
#include "nsMimeTypes.h"
|
||||
|
||||
|
||||
#define MIME_SUPERCLASS mimeLeafClass
|
||||
MimeDefClass(MimeExternalObject, MimeExternalObjectClass,
|
||||
mimeExternalObjectClass, &MIME_SUPERCLASS);
|
||||
mimeExternalObjectClass, &MIME_SUPERCLASS);
|
||||
|
||||
static int MimeExternalObject_initialize (MimeObject *);
|
||||
static void MimeExternalObject_finalize (MimeObject *);
|
||||
@@ -58,7 +57,7 @@ static int MimeExternalObject_parse_buffer (const char *, PRInt32, MimeObject *)
|
||||
static int MimeExternalObject_parse_line (const char *, PRInt32, MimeObject *);
|
||||
static int MimeExternalObject_parse_decoded_buffer (const char*, PRInt32, MimeObject*);
|
||||
static PRBool MimeExternalObject_displayable_inline_p (MimeObjectClass *clazz,
|
||||
MimeHeaders *hdrs);
|
||||
MimeHeaders *hdrs);
|
||||
|
||||
static int
|
||||
MimeExternalObjectClassInitialize(MimeExternalObjectClass *clazz)
|
||||
@@ -95,10 +94,10 @@ static int
|
||||
MimeExternalObject_parse_begin (MimeObject *obj)
|
||||
{
|
||||
int status;
|
||||
|
||||
|
||||
status = ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_begin(obj);
|
||||
if (status < 0) return status;
|
||||
|
||||
|
||||
// If we're writing this object, and we're doing it in raw form, then
|
||||
// now is the time to inform the backend what the type of this data is.
|
||||
//
|
||||
@@ -111,7 +110,7 @@ MimeExternalObject_parse_begin (MimeObject *obj)
|
||||
if (status < 0) return status;
|
||||
NS_ASSERTION(obj->options->state->first_data_written_p, "1.1 <rhp@netscape.com> 19 Mar 1999 12:00");
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// If we're writing this object as HTML, do all the work now -- just write
|
||||
// out a table with a link in it. (Later calls to the `parse_buffer' method
|
||||
@@ -122,29 +121,29 @@ MimeExternalObject_parse_begin (MimeObject *obj)
|
||||
obj->options->write_html_p &&
|
||||
obj->options->output_fn)
|
||||
{
|
||||
MimeDisplayOptions newopt = *obj->options; // copy it
|
||||
MimeDisplayOptions newopt = *obj->options; // copy it
|
||||
char *id = 0;
|
||||
char *id_url = 0;
|
||||
char *id_name = 0;
|
||||
nsCString id_imap;
|
||||
PRBool all_headers_p = obj->options->headers == MimeHeadersAll;
|
||||
|
||||
|
||||
id = mime_part_address (obj);
|
||||
if (obj->options->missing_parts)
|
||||
id_imap.Adopt(mime_imap_part_address (obj));
|
||||
if (! id) return MIME_OUT_OF_MEMORY;
|
||||
|
||||
|
||||
if (obj->options && obj->options->url)
|
||||
{
|
||||
const char *url = obj->options->url;
|
||||
if (!id_imap.IsEmpty() && id)
|
||||
{
|
||||
// if this is an IMAP part.
|
||||
// if this is an IMAP part.
|
||||
id_url = mime_set_url_imap_part(url, id_imap.get(), id);
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is just a normal MIME part as usual.
|
||||
// This is just a normal MIME part as usual.
|
||||
id_url = mime_set_url_part(url, id, PR_TRUE);
|
||||
}
|
||||
if (!id_url)
|
||||
@@ -153,14 +152,14 @@ MimeExternalObject_parse_begin (MimeObject *obj)
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
if (!nsCRT::strcmp (id, "0"))
|
||||
if (!strcmp (id, "0"))
|
||||
{
|
||||
PR_Free(id);
|
||||
id = MimeGetStringByID(MIME_MSG_ATTACHMENT);
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *p = "Part ";
|
||||
const char *p = "Part ";
|
||||
char *s = (char *)PR_MALLOC(strlen(p) + strlen(id) + 1);
|
||||
if (!s)
|
||||
{
|
||||
@@ -176,7 +175,7 @@ MimeExternalObject_parse_begin (MimeObject *obj)
|
||||
PR_Free(id);
|
||||
id = s;
|
||||
}
|
||||
|
||||
|
||||
if (all_headers_p &&
|
||||
// Don't bother showing all headers on this part if it's the only
|
||||
// part in the message: in that case, we've already shown these
|
||||
@@ -184,11 +183,11 @@ MimeExternalObject_parse_begin (MimeObject *obj)
|
||||
obj->options->state &&
|
||||
obj->options->state->root == obj->parent)
|
||||
all_headers_p = PR_FALSE;
|
||||
|
||||
newopt.fancy_headers_p = PR_TRUE;
|
||||
newopt.headers = (all_headers_p ? MimeHeadersAll : MimeHeadersSome);
|
||||
|
||||
/******
|
||||
newopt.fancy_headers_p = PR_TRUE;
|
||||
newopt.headers = (all_headers_p ? MimeHeadersAll : MimeHeadersSome);
|
||||
|
||||
/******
|
||||
RICHIE SHERRY
|
||||
GOTTA STILL DO THIS FOR QUOTING!
|
||||
status = MimeHeaders_write_attachment_box (obj->headers, &newopt,
|
||||
@@ -205,7 +204,7 @@ GOTTA STILL DO THIS FOR QUOTING!
|
||||
PR_FREEIF(id_name);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -216,43 +215,43 @@ MimeExternalObject_parse_buffer (const char *buffer, PRInt32 size, MimeObject *o
|
||||
if (obj->closed_p) return -1;
|
||||
|
||||
if (obj->output_p &&
|
||||
obj->options &&
|
||||
!obj->options->write_html_p)
|
||||
{
|
||||
/* The data will be base64-decoded and passed to
|
||||
MimeExternalObject_parse_decoded_buffer. */
|
||||
return ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_buffer(buffer, size,
|
||||
obj);
|
||||
}
|
||||
obj->options &&
|
||||
!obj->options->write_html_p)
|
||||
{
|
||||
/* The data will be base64-decoded and passed to
|
||||
MimeExternalObject_parse_decoded_buffer. */
|
||||
return ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_buffer(buffer, size,
|
||||
obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Otherwise, simply ignore the data. */
|
||||
return 0;
|
||||
}
|
||||
{
|
||||
/* Otherwise, simply ignore the data. */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
MimeExternalObject_parse_decoded_buffer (const char *buf, PRInt32 size,
|
||||
MimeObject *obj)
|
||||
MimeObject *obj)
|
||||
{
|
||||
/* This is called (by MimeLeafClass->parse_buffer) with blocks of data
|
||||
that have already been base64-decoded. This will only be called in
|
||||
the case where we're not emitting HTML, and want access to the raw
|
||||
data itself.
|
||||
that have already been base64-decoded. This will only be called in
|
||||
the case where we're not emitting HTML, and want access to the raw
|
||||
data itself.
|
||||
|
||||
We override the `parse_decoded_buffer' method provided by MimeLeaf
|
||||
because, unlike most children of MimeLeaf, we do not want to line-
|
||||
buffer the decoded data -- we want to simply pass it along to the
|
||||
backend, without going through our `parse_line' method.
|
||||
We override the `parse_decoded_buffer' method provided by MimeLeaf
|
||||
because, unlike most children of MimeLeaf, we do not want to line-
|
||||
buffer the decoded data -- we want to simply pass it along to the
|
||||
backend, without going through our `parse_line' method.
|
||||
*/
|
||||
if (!obj->output_p ||
|
||||
!obj->options ||
|
||||
obj->options->write_html_p)
|
||||
{
|
||||
NS_ASSERTION(0, "1.1 <rhp@netscape.com> 19 Mar 1999 12:00");
|
||||
return -1;
|
||||
}
|
||||
!obj->options ||
|
||||
obj->options->write_html_p)
|
||||
{
|
||||
NS_ASSERTION(0, "1.1 <rhp@netscape.com> 19 Mar 1999 12:00");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return MimeObject_write(obj, buf, size, PR_TRUE);
|
||||
}
|
||||
@@ -269,7 +268,7 @@ MimeExternalObject_parse_line (const char *line, PRInt32 length, MimeObject *obj
|
||||
|
||||
static PRBool
|
||||
MimeExternalObject_displayable_inline_p (MimeObjectClass *clazz,
|
||||
MimeHeaders *hdrs)
|
||||
MimeHeaders *hdrs)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
@@ -47,20 +47,20 @@
|
||||
Some parameters can't be affected that way, so some additional switches
|
||||
may be passed on the command line after the URL:
|
||||
|
||||
-fancy whether fancy headers should be generated (default)
|
||||
-fancy whether fancy headers should be generated (default)
|
||||
|
||||
-no-fancy opposite; this uses the headers used in the cases of
|
||||
FO_SAVE_AS_TEXT or FO_QUOTE_MESSAGE
|
||||
-no-fancy opposite; this uses the headers used in the cases of
|
||||
FO_SAVE_AS_TEXT or FO_QUOTE_MESSAGE
|
||||
|
||||
-html whether we should convert to HTML (like FO_PRESENT);
|
||||
this is the default if no ?part= is specified.
|
||||
-html whether we should convert to HTML (like FO_PRESENT);
|
||||
this is the default if no ?part= is specified.
|
||||
|
||||
-raw don't convert to HTML (FO_SAVE_AS);
|
||||
this is the default if a ?part= is specified.
|
||||
-raw don't convert to HTML (FO_SAVE_AS);
|
||||
this is the default if a ?part= is specified.
|
||||
|
||||
-outline at the end, print a debugging overview of the MIME structure
|
||||
-outline at the end, print a debugging overview of the MIME structure
|
||||
|
||||
Before any output comes a blurb listing the content-type, charset, and
|
||||
Before any output comes a blurb listing the content-type, charset, and
|
||||
various other info that would have been put in the generated URL struct.
|
||||
It's printed to the beginning of the output because otherwise this out-
|
||||
of-band data would have been lost. (So the output of this program is,
|
||||
@@ -78,8 +78,8 @@
|
||||
#include "nsMimeStringResources.h"
|
||||
|
||||
#ifndef XP_UNIX
|
||||
ERROR! This is a unix-only file for the "mimefilt" standalone program.
|
||||
This does not go into libmime.a.
|
||||
ERROR! This is a unix-only file for the "mimefilt" standalone program.
|
||||
This does not go into libmime.a.
|
||||
#endif
|
||||
|
||||
|
||||
@@ -88,58 +88,58 @@ test_file_type (const char *filename, void *stream_closure)
|
||||
{
|
||||
const char *suf = PL_strrchr(filename, '.');
|
||||
if (!suf)
|
||||
return 0;
|
||||
return 0;
|
||||
suf++;
|
||||
|
||||
if (!nsCRT::strcasecmp(suf, "txt") ||
|
||||
!nsCRT::strcasecmp(suf, "text"))
|
||||
return nsCRT::strdup("text/plain");
|
||||
else if (!nsCRT::strcasecmp(suf, "htm") ||
|
||||
!nsCRT::strcasecmp(suf, "html"))
|
||||
return nsCRT::strdup("text/html");
|
||||
else if (!nsCRT::strcasecmp(suf, "gif"))
|
||||
return nsCRT::strdup("image/gif");
|
||||
else if (!nsCRT::strcasecmp(suf, "jpg") ||
|
||||
!nsCRT::strcasecmp(suf, "jpeg"))
|
||||
return nsCRT::strdup("image/jpeg");
|
||||
else if (!nsCRT::strcasecmp(suf, "pjpg") ||
|
||||
!nsCRT::strcasecmp(suf, "pjpeg"))
|
||||
return nsCRT::strdup("image/pjpeg");
|
||||
else if (!nsCRT::strcasecmp(suf, "xbm"))
|
||||
return nsCRT::strdup("image/x-xbitmap");
|
||||
else if (!nsCRT::strcasecmp(suf, "xpm"))
|
||||
return nsCRT::strdup("image/x-xpixmap");
|
||||
else if (!nsCRT::strcasecmp(suf, "xwd"))
|
||||
return nsCRT::strdup("image/x-xwindowdump");
|
||||
else if (!nsCRT::strcasecmp(suf, "bmp"))
|
||||
return nsCRT::strdup("image/x-MS-bmp");
|
||||
else if (!nsCRT::strcasecmp(suf, "au"))
|
||||
return nsCRT::strdup("audio/basic");
|
||||
else if (!nsCRT::strcasecmp(suf, "aif") ||
|
||||
!nsCRT::strcasecmp(suf, "aiff") ||
|
||||
!nsCRT::strcasecmp(suf, "aifc"))
|
||||
return nsCRT::strdup("audio/x-aiff");
|
||||
else if (!nsCRT::strcasecmp(suf, "ps"))
|
||||
return nsCRT::strdup("application/postscript");
|
||||
if (!PL_strcasecmp(suf, "txt") ||
|
||||
!PL_strcasecmp(suf, "text"))
|
||||
return strdup("text/plain");
|
||||
else if (!PL_strcasecmp(suf, "htm") ||
|
||||
!PL_strcasecmp(suf, "html"))
|
||||
return strdup("text/html");
|
||||
else if (!PL_strcasecmp(suf, "gif"))
|
||||
return strdup("image/gif");
|
||||
else if (!PL_strcasecmp(suf, "jpg") ||
|
||||
!PL_strcasecmp(suf, "jpeg"))
|
||||
return strdup("image/jpeg");
|
||||
else if (!PL_strcasecmp(suf, "pjpg") ||
|
||||
!PL_strcasecmp(suf, "pjpeg"))
|
||||
return strdup("image/pjpeg");
|
||||
else if (!PL_strcasecmp(suf, "xbm"))
|
||||
return strdup("image/x-xbitmap");
|
||||
else if (!PL_strcasecmp(suf, "xpm"))
|
||||
return strdup("image/x-xpixmap");
|
||||
else if (!PL_strcasecmp(suf, "xwd"))
|
||||
return strdup("image/x-xwindowdump");
|
||||
else if (!PL_strcasecmp(suf, "bmp"))
|
||||
return strdup("image/x-MS-bmp");
|
||||
else if (!PL_strcasecmp(suf, "au"))
|
||||
return strdup("audio/basic");
|
||||
else if (!PL_strcasecmp(suf, "aif") ||
|
||||
!PL_strcasecmp(suf, "aiff") ||
|
||||
!PL_strcasecmp(suf, "aifc"))
|
||||
return strdup("audio/x-aiff");
|
||||
else if (!PL_strcasecmp(suf, "ps"))
|
||||
return strdup("application/postscript");
|
||||
else
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char *
|
||||
test_type_icon(const char *type, void *stream_closure)
|
||||
{
|
||||
if (!nsCRT::strncasecmp(type, "text/", 5))
|
||||
return nsCRT::strdup("resource://gre/res/html/gopher-text.gif");
|
||||
if (!nsCRT::strncasecmp(type, "image/", 6))
|
||||
return nsCRT::strdup("resource://gre/res/html/gopher-image.gif");
|
||||
if (!nsCRT::strncasecmp(type, "audio/", 6))
|
||||
return nsCRT::strdup("resource://gre/res/html/gopher-sound.gif");
|
||||
if (!nsCRT::strncasecmp(type, "video/", 6))
|
||||
return nsCRT::strdup("resource://gre/res/html/gopher-movie.gif");
|
||||
if (!nsCRT::strncasecmp(type, "application/", 12))
|
||||
return nsCRT::strdup("resource://gre/res/html/gopher-binary.gif");
|
||||
if (!PL_strncasecmp(type, "text/", 5))
|
||||
return strdup("resource://gre/res/html/gopher-text.gif");
|
||||
if (!PL_strncasecmp(type, "image/", 6))
|
||||
return strdup("resource://gre/res/html/gopher-image.gif");
|
||||
if (!PL_strncasecmp(type, "audio/", 6))
|
||||
return strdup("resource://gre/res/html/gopher-sound.gif");
|
||||
if (!PL_strncasecmp(type, "video/", 6))
|
||||
return strdup("resource://gre/res/html/gopher-movie.gif");
|
||||
if (!PL_strncasecmp(type, "application/", 12))
|
||||
return strdup("resource://gre/res/html/gopher-binary.gif");
|
||||
|
||||
return nsCRT::strdup("resource://gre/res/html/gopher-unknown.gif");
|
||||
return strdup("resource://gre/res/html/gopher-unknown.gif");
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -147,38 +147,38 @@ test_output_fn(char *buf, PRInt32 size, void *closure)
|
||||
{
|
||||
FILE *out = (FILE *) closure;
|
||||
if (out)
|
||||
return fwrite(buf, sizeof(*buf), size, out);
|
||||
return fwrite(buf, sizeof(*buf), size, out);
|
||||
else
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
test_output_init_fn (const char *type,
|
||||
const char *charset,
|
||||
const char *name,
|
||||
const char *x_mac_type,
|
||||
const char *x_mac_creator,
|
||||
void *stream_closure)
|
||||
const char *charset,
|
||||
const char *name,
|
||||
const char *x_mac_type,
|
||||
const char *x_mac_creator,
|
||||
void *stream_closure)
|
||||
{
|
||||
FILE *out = (FILE *) stream_closure;
|
||||
fprintf(out, "CONTENT-TYPE: %s", type);
|
||||
if (charset)
|
||||
fprintf(out, "; charset=\"%s\"", charset);
|
||||
fprintf(out, "; charset=\"%s\"", charset);
|
||||
if (name)
|
||||
fprintf(out, "; name=\"%s\"", name);
|
||||
fprintf(out, "; name=\"%s\"", name);
|
||||
if (x_mac_type || x_mac_creator)
|
||||
fprintf(out, "; x-mac-type=\"%s\"; x-mac-creator=\"%s\"",
|
||||
x_mac_type ? x_mac_type : "",
|
||||
x_mac_creator ? x_mac_type : "");
|
||||
fprintf(out, "; x-mac-type=\"%s\"; x-mac-creator=\"%s\"",
|
||||
x_mac_type ? x_mac_type : "",
|
||||
x_mac_creator ? x_mac_type : "");
|
||||
fprintf(out, CRLF CRLF);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void *
|
||||
test_image_begin(const char *image_url, const char *content_type,
|
||||
void *stream_closure)
|
||||
void *stream_closure)
|
||||
{
|
||||
return ((void *) nsCRT::strdup(image_url));
|
||||
return ((void *) strdup(image_url));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -197,14 +197,14 @@ test_image_make_image_html(void *image_data)
|
||||
const char *suffix = "\"></CENTER><P>";
|
||||
#else
|
||||
const char *prefix = ("<P><CENTER><TABLE BORDER=2 CELLPADDING=20"
|
||||
" BGCOLOR=WHITE>"
|
||||
"<TR><TD ALIGN=CENTER>"
|
||||
"an inlined image would have gone here for<BR>");
|
||||
" BGCOLOR=WHITE>"
|
||||
"<TR><TD ALIGN=CENTER>"
|
||||
"an inlined image would have gone here for<BR>");
|
||||
const char *suffix = "</TD></TR></TABLE></CENTER><P>";
|
||||
#endif
|
||||
char *buf;
|
||||
buf = (char *) PR_MALLOC (nsCRT::strlen (prefix) + nsCRT::strlen (suffix) +
|
||||
nsCRT::strlen (url) + 20);
|
||||
buf = (char *) PR_MALLOC (strlen (prefix) + strlen (suffix) +
|
||||
strlen (url) + 20);
|
||||
if (!buf) return 0;
|
||||
*buf = 0;
|
||||
PL_strcat (buf, prefix);
|
||||
@@ -225,21 +225,21 @@ test_passwd_prompt (PK11SlotInfo *slot, void *wincx)
|
||||
fprintf(stdout, "#### Password required: ");
|
||||
s = fgets(buf, sizeof(buf)-1, stdin);
|
||||
if (!s) return s;
|
||||
if (s[nsCRT::strlen(s)-1] == '\r' ||
|
||||
s[nsCRT::strlen(s)-1] == '\n')
|
||||
s[nsCRT::strlen(s)-1] = '\0';
|
||||
if (s[strlen(s)-1] == '\r' ||
|
||||
s[strlen(s)-1] == '\n')
|
||||
s[strlen(s)-1] = '\0';
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
test(FILE *in, FILE *out,
|
||||
const char *url,
|
||||
PRBool fancy_headers_p,
|
||||
PRBool html_p,
|
||||
PRBool outline_p,
|
||||
PRBool dexlate_p,
|
||||
PRBool variable_width_plaintext_p)
|
||||
const char *url,
|
||||
PRBool fancy_headers_p,
|
||||
PRBool html_p,
|
||||
PRBool outline_p,
|
||||
PRBool dexlate_p,
|
||||
PRBool variable_width_plaintext_p)
|
||||
{
|
||||
int status = 0;
|
||||
MimeObject *obj = 0;
|
||||
@@ -254,80 +254,80 @@ test(FILE *in, FILE *out,
|
||||
|
||||
status = mime_parse_url_options(url, opt);
|
||||
if (status < 0)
|
||||
{
|
||||
PR_Free(opt);
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
{
|
||||
PR_Free(opt);
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
opt->url = url;
|
||||
opt->write_html_p = html_p;
|
||||
opt->dexlate_p = dexlate_p;
|
||||
opt->output_init_fn = test_output_init_fn;
|
||||
opt->output_fn = test_output_fn;
|
||||
opt->url = url;
|
||||
opt->write_html_p = html_p;
|
||||
opt->dexlate_p = dexlate_p;
|
||||
opt->output_init_fn = test_output_init_fn;
|
||||
opt->output_fn = test_output_fn;
|
||||
opt->charset_conversion_fn= 0;
|
||||
opt->rfc1522_conversion_p = PR_FALSE;
|
||||
opt->file_type_fn = test_file_type;
|
||||
opt->stream_closure = out;
|
||||
opt->file_type_fn = test_file_type;
|
||||
opt->stream_closure = out;
|
||||
|
||||
opt->image_begin = test_image_begin;
|
||||
opt->image_end = test_image_end;
|
||||
opt->make_image_html = test_image_make_image_html;
|
||||
opt->image_write_buffer = test_image_write_buffer;
|
||||
opt->image_begin = test_image_begin;
|
||||
opt->image_end = test_image_end;
|
||||
opt->make_image_html = test_image_make_image_html;
|
||||
opt->image_write_buffer = test_image_write_buffer;
|
||||
|
||||
opt->variable_width_plaintext_p = variable_width_plaintext_p;
|
||||
|
||||
obj = mime_new ((MimeObjectClass *)&mimeMessageClass,
|
||||
(MimeHeaders *) NULL,
|
||||
MESSAGE_RFC822);
|
||||
(MimeHeaders *) NULL,
|
||||
MESSAGE_RFC822);
|
||||
if (!obj)
|
||||
{
|
||||
PR_Free(opt);
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
{
|
||||
PR_Free(opt);
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
obj->options = opt;
|
||||
|
||||
status = obj->class->initialize(obj);
|
||||
if (status >= 0)
|
||||
status = obj->class->parse_begin(obj);
|
||||
status = obj->class->parse_begin(obj);
|
||||
if (status < 0)
|
||||
{
|
||||
PR_Free(opt);
|
||||
PR_Free(obj);
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
{
|
||||
PR_Free(opt);
|
||||
PR_Free(obj);
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
char buf[255];
|
||||
int size = fread(buf, sizeof(*buf), sizeof(buf), stdin);
|
||||
if (size <= 0) break;
|
||||
status = obj->class->parse_buffer(buf, size, obj);
|
||||
if (status < 0)
|
||||
{
|
||||
mime_free(obj);
|
||||
PR_Free(opt);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
{
|
||||
char buf[255];
|
||||
int size = fread(buf, sizeof(*buf), sizeof(buf), stdin);
|
||||
if (size <= 0) break;
|
||||
status = obj->class->parse_buffer(buf, size, obj);
|
||||
if (status < 0)
|
||||
{
|
||||
mime_free(obj);
|
||||
PR_Free(opt);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
status = obj->class->parse_eof(obj, PR_FALSE);
|
||||
if (status >= 0)
|
||||
status = obj->class->parse_end(obj, PR_FALSE);
|
||||
status = obj->class->parse_end(obj, PR_FALSE);
|
||||
if (status < 0)
|
||||
{
|
||||
mime_free(obj);
|
||||
PR_Free(opt);
|
||||
return status;
|
||||
}
|
||||
{
|
||||
mime_free(obj);
|
||||
PR_Free(opt);
|
||||
return status;
|
||||
}
|
||||
|
||||
if (outline_p)
|
||||
{
|
||||
fprintf(out, "\n\n"
|
||||
"###############################################################\n");
|
||||
obj->class->debug_print(obj, stderr, 0);
|
||||
fprintf(out,
|
||||
"###############################################################\n");
|
||||
}
|
||||
{
|
||||
fprintf(out, "\n\n"
|
||||
"###############################################################\n");
|
||||
obj->class->debug_print(obj, stderr, 0);
|
||||
fprintf(out,
|
||||
"###############################################################\n");
|
||||
}
|
||||
|
||||
mime_free (obj);
|
||||
PR_Free(opt);
|
||||
@@ -340,9 +340,9 @@ test_cdb_name_cb (void *arg, int vers)
|
||||
{
|
||||
static char f[1024];
|
||||
if (vers <= 4)
|
||||
sprintf(f, "%s/.netscape/cert.db", getenv("HOME"));
|
||||
sprintf(f, "%s/.netscape/cert.db", getenv("HOME"));
|
||||
else
|
||||
sprintf(f, "%s/.netscape/cert%d.db", getenv("HOME"), vers);
|
||||
sprintf(f, "%s/.netscape/cert%d.db", getenv("HOME"), vers);
|
||||
return f;
|
||||
}
|
||||
|
||||
@@ -351,9 +351,9 @@ test_kdb_name_cb (void *arg, int vers)
|
||||
{
|
||||
static char f[1024];
|
||||
if (vers <= 2)
|
||||
sprintf(f, "%s/.netscape/key.db", getenv("HOME"));
|
||||
sprintf(f, "%s/.netscape/key.db", getenv("HOME"));
|
||||
else
|
||||
sprintf(f, "%s/.netscape/key%d.db", getenv("HOME"), vers);
|
||||
sprintf(f, "%s/.netscape/key%d.db", getenv("HOME"), vers);
|
||||
return f;
|
||||
}
|
||||
|
||||
@@ -377,7 +377,7 @@ main (int argc, char **argv)
|
||||
cdb_handle = (CERTCertDBHandle *) calloc(1, sizeof(*cdb_handle));
|
||||
|
||||
if (SECSuccess != CERT_OpenCertDB(cdb_handle, PR_FALSE, test_cdb_name_cb, NULL))
|
||||
CERT_OpenVolatileCertDB(cdb_handle);
|
||||
CERT_OpenVolatileCertDB(cdb_handle);
|
||||
CERT_SetDefaultCertDB(cdb_handle);
|
||||
|
||||
RNG_RNGInit();
|
||||
@@ -394,45 +394,45 @@ main (int argc, char **argv)
|
||||
|
||||
|
||||
if (i < argc)
|
||||
{
|
||||
if (argv[i][0] == '-')
|
||||
url = nsCRT::strdup("");
|
||||
else
|
||||
url = argv[i++];
|
||||
}
|
||||
{
|
||||
if (argv[i][0] == '-')
|
||||
url = strdup("");
|
||||
else
|
||||
url = argv[i++];
|
||||
}
|
||||
|
||||
if (url &&
|
||||
(PL_strstr(url, "?part=") ||
|
||||
PL_strstr(url, "&part=")))
|
||||
html_p = PR_FALSE;
|
||||
(PL_strstr(url, "?part=") ||
|
||||
PL_strstr(url, "&part=")))
|
||||
html_p = PR_FALSE;
|
||||
|
||||
while (i < argc)
|
||||
{
|
||||
if (!nsCRT::strcmp(argv[i], "-fancy"))
|
||||
fancy_p = PR_TRUE;
|
||||
else if (!nsCRT::strcmp(argv[i], "-no-fancy"))
|
||||
fancy_p = PR_FALSE;
|
||||
else if (!nsCRT::strcmp(argv[i], "-html"))
|
||||
html_p = PR_TRUE;
|
||||
else if (!nsCRT::strcmp(argv[i], "-raw"))
|
||||
html_p = PR_FALSE;
|
||||
else if (!nsCRT::strcmp(argv[i], "-outline"))
|
||||
outline_p = PR_TRUE;
|
||||
else if (!nsCRT::strcmp(argv[i], "-dexlate"))
|
||||
dexlate_p = PR_TRUE;
|
||||
else
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: %s [ URL [ -fancy | -no-fancy | -html | -raw | -outline | -dexlate ]]\n"
|
||||
" < message/rfc822 > output\n",
|
||||
(PL_strrchr(argv[0], '/') ?
|
||||
PL_strrchr(argv[0], '/') + 1 :
|
||||
argv[0]));
|
||||
i = 1;
|
||||
goto FAIL;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
{
|
||||
if (!strcmp(argv[i], "-fancy"))
|
||||
fancy_p = PR_TRUE;
|
||||
else if (!strcmp(argv[i], "-no-fancy"))
|
||||
fancy_p = PR_FALSE;
|
||||
else if (!strcmp(argv[i], "-html"))
|
||||
html_p = PR_TRUE;
|
||||
else if (!strcmp(argv[i], "-raw"))
|
||||
html_p = PR_FALSE;
|
||||
else if (!strcmp(argv[i], "-outline"))
|
||||
outline_p = PR_TRUE;
|
||||
else if (!strcmp(argv[i], "-dexlate"))
|
||||
dexlate_p = PR_TRUE;
|
||||
else
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: %s [ URL [ -fancy | -no-fancy | -html | -raw | -outline | -dexlate ]]\n"
|
||||
" < message/rfc822 > output\n",
|
||||
(PL_strrchr(argv[0], '/') ?
|
||||
PL_strrchr(argv[0], '/') + 1 :
|
||||
argv[0]));
|
||||
i = 1;
|
||||
goto FAIL;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
i = test(stdin, stdout, url, fancy_p, html_p, outline_p, dexlate_p, PR_TRUE);
|
||||
fprintf(stdout, "\n");
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
#include "mimebuf.h"
|
||||
#include "mimemoz2.h"
|
||||
#include "nsIMimeEmitter.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsMsgMessageFlags.h"
|
||||
#include "comi18n.h"
|
||||
@@ -53,7 +52,7 @@
|
||||
#include "mimemoz2.h"
|
||||
#include "nsMsgI18N.h"
|
||||
#include "mimehdrs.h"
|
||||
#include "nsIMIMEHeaderParam.h"
|
||||
#include "nsIMIMEHeaderParam.h"
|
||||
#include "nsNetCID.h"
|
||||
|
||||
// Forward declares...
|
||||
@@ -113,10 +112,10 @@ MimeHeaders_free (MimeHeaders *hdrs)
|
||||
|
||||
# ifdef DEBUG__
|
||||
{
|
||||
int i, size = sizeof(*hdrs);
|
||||
PRUint32 *array = (PRUint32*) hdrs;
|
||||
for (i = 0; i < (size / sizeof(*array)); i++)
|
||||
array[i] = (PRUint32) 0xDEADBEEF;
|
||||
int i, size = sizeof(*hdrs);
|
||||
PRUint32 *array = (PRUint32*) hdrs;
|
||||
for (i = 0; i < (size / sizeof(*array)); i++)
|
||||
array[i] = (PRUint32) 0xDEADBEEF;
|
||||
}
|
||||
# endif /* DEBUG */
|
||||
|
||||
@@ -137,22 +136,22 @@ MimeHeaders_parse_line (const char *buffer, PRInt32 size, MimeHeaders *hdrs)
|
||||
if (hdrs->done_p) return -1;
|
||||
|
||||
if (!buffer || size == 0 || *buffer == '\r' || *buffer == '\n')
|
||||
{
|
||||
/* If this is a blank line, we're done.
|
||||
*/
|
||||
hdrs->done_p = PR_TRUE;
|
||||
return MimeHeaders_build_heads_list(hdrs);
|
||||
}
|
||||
{
|
||||
/* If this is a blank line, we're done.
|
||||
*/
|
||||
hdrs->done_p = PR_TRUE;
|
||||
return MimeHeaders_build_heads_list(hdrs);
|
||||
}
|
||||
|
||||
/* Tack this data on to the end of our copy.
|
||||
*/
|
||||
desired_size = hdrs->all_headers_fp + size + 1;
|
||||
if (desired_size >= hdrs->all_headers_size)
|
||||
{
|
||||
status = mime_GrowBuffer (desired_size, sizeof(char), 255,
|
||||
&hdrs->all_headers, &hdrs->all_headers_size);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
{
|
||||
status = mime_GrowBuffer (desired_size, sizeof(char), 255,
|
||||
&hdrs->all_headers, &hdrs->all_headers_size);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
memcpy(hdrs->all_headers+hdrs->all_headers_fp, buffer, size);
|
||||
hdrs->all_headers_fp += size;
|
||||
|
||||
@@ -170,39 +169,39 @@ MimeHeaders_copy (MimeHeaders *hdrs)
|
||||
memset(hdrs2, 0, sizeof(*hdrs2));
|
||||
|
||||
if (hdrs->all_headers)
|
||||
{
|
||||
hdrs2->all_headers = (char *) PR_MALLOC(hdrs->all_headers_fp);
|
||||
if (!hdrs2->all_headers)
|
||||
{
|
||||
PR_Free(hdrs2);
|
||||
return 0;
|
||||
}
|
||||
memcpy(hdrs2->all_headers, hdrs->all_headers, hdrs->all_headers_fp);
|
||||
{
|
||||
hdrs2->all_headers = (char *) PR_MALLOC(hdrs->all_headers_fp);
|
||||
if (!hdrs2->all_headers)
|
||||
{
|
||||
PR_Free(hdrs2);
|
||||
return 0;
|
||||
}
|
||||
memcpy(hdrs2->all_headers, hdrs->all_headers, hdrs->all_headers_fp);
|
||||
|
||||
hdrs2->all_headers_fp = hdrs->all_headers_fp;
|
||||
hdrs2->all_headers_size = hdrs->all_headers_fp;
|
||||
}
|
||||
hdrs2->all_headers_fp = hdrs->all_headers_fp;
|
||||
hdrs2->all_headers_size = hdrs->all_headers_fp;
|
||||
}
|
||||
|
||||
hdrs2->done_p = hdrs->done_p;
|
||||
|
||||
if (hdrs->heads)
|
||||
{
|
||||
int i;
|
||||
hdrs2->heads = (char **) PR_MALLOC(hdrs->heads_size
|
||||
* sizeof(*hdrs->heads));
|
||||
if (!hdrs2->heads)
|
||||
{
|
||||
PR_FREEIF(hdrs2->all_headers);
|
||||
PR_Free(hdrs2);
|
||||
return 0;
|
||||
}
|
||||
hdrs2->heads_size = hdrs->heads_size;
|
||||
for (i = 0; i < hdrs->heads_size; i++)
|
||||
{
|
||||
hdrs2->heads[i] = (hdrs2->all_headers +
|
||||
(hdrs->heads[i] - hdrs->all_headers));
|
||||
}
|
||||
}
|
||||
{
|
||||
int i;
|
||||
hdrs2->heads = (char **) PR_MALLOC(hdrs->heads_size
|
||||
* sizeof(*hdrs->heads));
|
||||
if (!hdrs2->heads)
|
||||
{
|
||||
PR_FREEIF(hdrs2->all_headers);
|
||||
PR_Free(hdrs2);
|
||||
return 0;
|
||||
}
|
||||
hdrs2->heads_size = hdrs->heads_size;
|
||||
for (i = 0; i < hdrs->heads_size; i++)
|
||||
{
|
||||
hdrs2->heads[i] = (hdrs2->all_headers +
|
||||
(hdrs->heads[i] - hdrs->all_headers));
|
||||
}
|
||||
}
|
||||
return hdrs2;
|
||||
}
|
||||
|
||||
@@ -217,55 +216,55 @@ MimeHeaders_build_heads_list(MimeHeaders *hdrs)
|
||||
|
||||
NS_ASSERTION(hdrs->done_p && !hdrs->heads, "1.1 <rhp@netscape.com> 19 Mar 1999 12:00");
|
||||
if (!hdrs->done_p || hdrs->heads)
|
||||
return -1;
|
||||
return -1;
|
||||
|
||||
if (hdrs->all_headers_fp == 0)
|
||||
{
|
||||
/* Must not have been any headers (we got the blank line right away.) */
|
||||
PR_FREEIF (hdrs->all_headers);
|
||||
hdrs->all_headers_size = 0;
|
||||
return 0;
|
||||
}
|
||||
{
|
||||
/* Must not have been any headers (we got the blank line right away.) */
|
||||
PR_FREEIF (hdrs->all_headers);
|
||||
hdrs->all_headers_size = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* At this point, we might as well realloc all_headers back down to the
|
||||
minimum size it must be (it could be up to 1k bigger.) But don't
|
||||
bother if we're only off by a tiny bit. */
|
||||
minimum size it must be (it could be up to 1k bigger.) But don't
|
||||
bother if we're only off by a tiny bit. */
|
||||
NS_ASSERTION(hdrs->all_headers_fp <= hdrs->all_headers_size, "1.1 <rhp@netscape.com> 19 Mar 1999 12:00");
|
||||
if (hdrs->all_headers_fp + 60 <= hdrs->all_headers_size)
|
||||
{
|
||||
char *ls = (char *)PR_Realloc(hdrs->all_headers, hdrs->all_headers_fp);
|
||||
if (ls) /* can this ever fail? we're making it smaller... */
|
||||
{
|
||||
hdrs->all_headers = ls; /* in case it got relocated */
|
||||
hdrs->all_headers_size = hdrs->all_headers_fp;
|
||||
}
|
||||
}
|
||||
{
|
||||
char *ls = (char *)PR_Realloc(hdrs->all_headers, hdrs->all_headers_fp);
|
||||
if (ls) /* can this ever fail? we're making it smaller... */
|
||||
{
|
||||
hdrs->all_headers = ls; /* in case it got relocated */
|
||||
hdrs->all_headers_size = hdrs->all_headers_fp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* First go through and count up the number of headers in the block.
|
||||
*/
|
||||
end = hdrs->all_headers + hdrs->all_headers_fp;
|
||||
for (s = hdrs->all_headers; s <= end-1; s++)
|
||||
{
|
||||
if (s <= (end-1) && s[0] == '\r' && s[1] == '\n') /* CRLF -> LF */
|
||||
s++;
|
||||
{
|
||||
if (s <= (end-1) && s[0] == '\r' && s[1] == '\n') /* CRLF -> LF */
|
||||
s++;
|
||||
|
||||
if ((s[0] == '\r' || s[0] == '\n') && /* we're at a newline, and */
|
||||
(s >= (end-1) || /* we're at EOF, or */
|
||||
!(s[1] == ' ' || s[1] == '\t'))) /* next char is nonwhite */
|
||||
hdrs->heads_size++;
|
||||
}
|
||||
|
||||
if ((s[0] == '\r' || s[0] == '\n') && /* we're at a newline, and */
|
||||
(s >= (end-1) || /* we're at EOF, or */
|
||||
!(s[1] == ' ' || s[1] == '\t'))) /* next char is nonwhite */
|
||||
hdrs->heads_size++;
|
||||
}
|
||||
|
||||
/* Now allocate storage for the pointers to each of those headers.
|
||||
*/
|
||||
hdrs->heads = (char **) PR_MALLOC((hdrs->heads_size + 1) * sizeof(char *));
|
||||
if (!hdrs->heads)
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
memset(hdrs->heads, 0, (hdrs->heads_size + 1) * sizeof(char *));
|
||||
|
||||
|
||||
/* Now make another pass through the headers, and this time, record the
|
||||
starting position of each header.
|
||||
starting position of each header.
|
||||
*/
|
||||
|
||||
i = 0;
|
||||
@@ -273,51 +272,51 @@ MimeHeaders_build_heads_list(MimeHeaders *hdrs)
|
||||
s = hdrs->all_headers;
|
||||
|
||||
while (s <= end)
|
||||
{
|
||||
SEARCH_NEWLINE:
|
||||
while (s <= end-1 && *s != '\r' && *s != '\n')
|
||||
s++;
|
||||
{
|
||||
SEARCH_NEWLINE:
|
||||
while (s <= end-1 && *s != '\r' && *s != '\n')
|
||||
s++;
|
||||
|
||||
if (s+1 >= end)
|
||||
break;
|
||||
if (s+1 >= end)
|
||||
break;
|
||||
|
||||
/* If "\r\n " or "\r\n\t" is next, that doesn't terminate the header. */
|
||||
else if (s+2 < end &&
|
||||
(s[0] == '\r' && s[1] == '\n') &&
|
||||
(s[2] == ' ' || s[2] == '\t'))
|
||||
{
|
||||
s += 3;
|
||||
goto SEARCH_NEWLINE;
|
||||
}
|
||||
/* If "\r " or "\r\t" or "\n " or "\n\t" is next, that doesn't terminate
|
||||
the header either. */
|
||||
else if ((s[0] == '\r' || s[0] == '\n') &&
|
||||
(s[1] == ' ' || s[1] == '\t'))
|
||||
{
|
||||
s += 2;
|
||||
goto SEARCH_NEWLINE;
|
||||
}
|
||||
/* If "\r\n " or "\r\n\t" is next, that doesn't terminate the header. */
|
||||
else if (s+2 < end &&
|
||||
(s[0] == '\r' && s[1] == '\n') &&
|
||||
(s[2] == ' ' || s[2] == '\t'))
|
||||
{
|
||||
s += 3;
|
||||
goto SEARCH_NEWLINE;
|
||||
}
|
||||
/* If "\r " or "\r\t" or "\n " or "\n\t" is next, that doesn't terminate
|
||||
the header either. */
|
||||
else if ((s[0] == '\r' || s[0] == '\n') &&
|
||||
(s[1] == ' ' || s[1] == '\t'))
|
||||
{
|
||||
s += 2;
|
||||
goto SEARCH_NEWLINE;
|
||||
}
|
||||
|
||||
/* At this point, `s' points before a header-terminating newline.
|
||||
Move past that newline, and store that new position in `heads'.
|
||||
*/
|
||||
if (*s == '\r') s++;
|
||||
if (*s == '\n') s++;
|
||||
/* At this point, `s' points before a header-terminating newline.
|
||||
Move past that newline, and store that new position in `heads'.
|
||||
*/
|
||||
if (*s == '\r') s++;
|
||||
if (*s == '\n') s++;
|
||||
|
||||
if (s < end)
|
||||
{
|
||||
NS_ASSERTION(! (i > hdrs->heads_size), "1.1 <rhp@netscape.com> 19 Mar 1999 12:00");
|
||||
if (i > hdrs->heads_size) return -1;
|
||||
hdrs->heads[i++] = s;
|
||||
}
|
||||
}
|
||||
if (s < end)
|
||||
{
|
||||
NS_ASSERTION(! (i > hdrs->heads_size), "1.1 <rhp@netscape.com> 19 Mar 1999 12:00");
|
||||
if (i > hdrs->heads_size) return -1;
|
||||
hdrs->heads[i++] = s;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *
|
||||
MimeHeaders_get (MimeHeaders *hdrs, const char *header_name,
|
||||
PRBool strip_p, PRBool all_p)
|
||||
PRBool strip_p, PRBool all_p)
|
||||
{
|
||||
int i;
|
||||
int name_length;
|
||||
@@ -332,177 +331,177 @@ MimeHeaders_get (MimeHeaders *hdrs, const char *header_name,
|
||||
NS_ASSERTION(!(strip_p && all_p), "1.1 <rhp@netscape.com> 19 Mar 1999 12:00");
|
||||
|
||||
/* One shouldn't be trying to read headers when one hasn't finished
|
||||
parsing them yet... but this can happen if the message ended
|
||||
prematurely, and has no body at all (as opposed to a null body,
|
||||
which is more normal.) So, if we try to read from the headers,
|
||||
let's assume that the headers are now finished. If they aren't
|
||||
in fact finished, then a later attempt to write to them will assert.
|
||||
parsing them yet... but this can happen if the message ended
|
||||
prematurely, and has no body at all (as opposed to a null body,
|
||||
which is more normal.) So, if we try to read from the headers,
|
||||
let's assume that the headers are now finished. If they aren't
|
||||
in fact finished, then a later attempt to write to them will assert.
|
||||
*/
|
||||
if (!hdrs->done_p)
|
||||
{
|
||||
int status;
|
||||
hdrs->done_p = PR_TRUE;
|
||||
status = MimeHeaders_build_heads_list(hdrs);
|
||||
if (status < 0) return 0;
|
||||
}
|
||||
{
|
||||
int status;
|
||||
hdrs->done_p = PR_TRUE;
|
||||
status = MimeHeaders_build_heads_list(hdrs);
|
||||
if (status < 0) return 0;
|
||||
}
|
||||
|
||||
if (!hdrs->heads) /* Must not have been any headers. */
|
||||
{
|
||||
NS_ASSERTION(hdrs->all_headers_fp == 0, "1.1 <rhp@netscape.com> 19 Mar 1999 12:00");
|
||||
return 0;
|
||||
}
|
||||
if (!hdrs->heads) /* Must not have been any headers. */
|
||||
{
|
||||
NS_ASSERTION(hdrs->all_headers_fp == 0, "1.1 <rhp@netscape.com> 19 Mar 1999 12:00");
|
||||
return 0;
|
||||
}
|
||||
|
||||
name_length = strlen(header_name);
|
||||
|
||||
for (i = 0; i < hdrs->heads_size; i++)
|
||||
{
|
||||
char *head = hdrs->heads[i];
|
||||
char *end = (i == hdrs->heads_size-1
|
||||
? hdrs->all_headers + hdrs->all_headers_fp
|
||||
: hdrs->heads[i+1]);
|
||||
char *colon, *ocolon;
|
||||
{
|
||||
char *head = hdrs->heads[i];
|
||||
char *end = (i == hdrs->heads_size-1
|
||||
? hdrs->all_headers + hdrs->all_headers_fp
|
||||
: hdrs->heads[i+1]);
|
||||
char *colon, *ocolon;
|
||||
|
||||
NS_ASSERTION(head, "1.1 <rhp@netscape.com> 19 Mar 1999 12:00");
|
||||
if (!head) continue;
|
||||
NS_ASSERTION(head, "1.1 <rhp@netscape.com> 19 Mar 1999 12:00");
|
||||
if (!head) continue;
|
||||
|
||||
/* Quick hack to skip over BSD Mailbox delimiter. */
|
||||
if (i == 0 && head[0] == 'F' && !strncmp(head, "From ", 5))
|
||||
continue;
|
||||
/* Quick hack to skip over BSD Mailbox delimiter. */
|
||||
if (i == 0 && head[0] == 'F' && !strncmp(head, "From ", 5))
|
||||
continue;
|
||||
|
||||
/* Find the colon. */
|
||||
for (colon = head; colon < end; colon++)
|
||||
if (*colon == ':') break;
|
||||
/* Find the colon. */
|
||||
for (colon = head; colon < end; colon++)
|
||||
if (*colon == ':') break;
|
||||
|
||||
if (colon >= end) continue;
|
||||
if (colon >= end) continue;
|
||||
|
||||
/* Back up over whitespace before the colon. */
|
||||
ocolon = colon;
|
||||
for (; colon > head && nsCRT::IsAsciiSpace(colon[-1]); colon--)
|
||||
;
|
||||
/* Back up over whitespace before the colon. */
|
||||
ocolon = colon;
|
||||
for (; colon > head && IS_SPACE(colon[-1]); colon--)
|
||||
;
|
||||
|
||||
/* If the strings aren't the same length, it doesn't match. */
|
||||
if (name_length != colon - head )
|
||||
continue;
|
||||
/* If the strings aren't the same length, it doesn't match. */
|
||||
if (name_length != colon - head )
|
||||
continue;
|
||||
|
||||
/* If the strings differ, it doesn't match. */
|
||||
if (nsCRT::strncasecmp(header_name, head, name_length))
|
||||
continue;
|
||||
/* If the strings differ, it doesn't match. */
|
||||
if (PL_strncasecmp(header_name, head, name_length))
|
||||
continue;
|
||||
|
||||
/* Otherwise, we've got a match. */
|
||||
{
|
||||
char *contents = ocolon + 1;
|
||||
char *s;
|
||||
/* Otherwise, we've got a match. */
|
||||
{
|
||||
char *contents = ocolon + 1;
|
||||
char *s;
|
||||
|
||||
/* Skip over whitespace after colon. */
|
||||
while (contents <= end && nsCRT::IsAsciiSpace(*contents))
|
||||
contents++;
|
||||
/* Skip over whitespace after colon. */
|
||||
while (contents <= end && IS_SPACE(*contents))
|
||||
contents++;
|
||||
|
||||
/* If we're supposed to strip at the first token, pull `end' back to
|
||||
the first whitespace or ';' after the first token.
|
||||
*/
|
||||
if (strip_p)
|
||||
{
|
||||
for (s = contents;
|
||||
s <= end && *s != ';' && *s != ',' && !nsCRT::IsAsciiSpace(*s);
|
||||
s++)
|
||||
;
|
||||
end = s;
|
||||
}
|
||||
/* If we're supposed to strip at the first token, pull `end' back to
|
||||
the first whitespace or ';' after the first token.
|
||||
*/
|
||||
if (strip_p)
|
||||
{
|
||||
for (s = contents;
|
||||
s <= end && *s != ';' && *s != ',' && !IS_SPACE(*s);
|
||||
s++)
|
||||
;
|
||||
end = s;
|
||||
}
|
||||
|
||||
/* Now allocate some storage.
|
||||
If `result' already has a value, enlarge it.
|
||||
Otherwise, just allocate a block.
|
||||
`s' gets set to the place where the new data goes.
|
||||
*/
|
||||
if (!result)
|
||||
{
|
||||
result = (char *) PR_MALLOC(end - contents + 1);
|
||||
if (!result)
|
||||
return 0;
|
||||
s = result;
|
||||
}
|
||||
else
|
||||
{
|
||||
PRInt32 L = strlen(result);
|
||||
s = (char *) PR_Realloc(result, (L + (end - contents + 10)));
|
||||
if (!s)
|
||||
{
|
||||
PR_Free(result);
|
||||
return 0;
|
||||
}
|
||||
result = s;
|
||||
s = result + L;
|
||||
/* Now allocate some storage.
|
||||
If `result' already has a value, enlarge it.
|
||||
Otherwise, just allocate a block.
|
||||
`s' gets set to the place where the new data goes.
|
||||
*/
|
||||
if (!result)
|
||||
{
|
||||
result = (char *) PR_MALLOC(end - contents + 1);
|
||||
if (!result)
|
||||
return 0;
|
||||
s = result;
|
||||
}
|
||||
else
|
||||
{
|
||||
PRInt32 L = strlen(result);
|
||||
s = (char *) PR_Realloc(result, (L + (end - contents + 10)));
|
||||
if (!s)
|
||||
{
|
||||
PR_Free(result);
|
||||
return 0;
|
||||
}
|
||||
result = s;
|
||||
s = result + L;
|
||||
|
||||
/* Since we are tacking more data onto the end of the header
|
||||
field, we must make it be a well-formed continuation line,
|
||||
/* Since we are tacking more data onto the end of the header
|
||||
field, we must make it be a well-formed continuation line,
|
||||
by separating the old and new data with CR-LF-TAB.
|
||||
*/
|
||||
*s++ = ','; /* #### only do this for addr headers? */
|
||||
*s++ = MSG_LINEBREAK[0];
|
||||
*/
|
||||
*s++ = ','; /* #### only do this for addr headers? */
|
||||
*s++ = MSG_LINEBREAK[0];
|
||||
# if (MSG_LINEBREAK_LEN == 2)
|
||||
*s++ = MSG_LINEBREAK[1];
|
||||
*s++ = MSG_LINEBREAK[1];
|
||||
# endif
|
||||
*s++ = '\t';
|
||||
}
|
||||
*s++ = '\t';
|
||||
}
|
||||
|
||||
/* Take off trailing whitespace... */
|
||||
while (end > contents && nsCRT::IsAsciiSpace(end[-1]))
|
||||
end--;
|
||||
/* Take off trailing whitespace... */
|
||||
while (end > contents && IS_SPACE(end[-1]))
|
||||
end--;
|
||||
|
||||
if (end > contents)
|
||||
{
|
||||
/* Now copy the header's contents in...
|
||||
*/
|
||||
memcpy(s, contents, end - contents);
|
||||
s[end - contents] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
s[0] = 0;
|
||||
}
|
||||
if (end > contents)
|
||||
{
|
||||
/* Now copy the header's contents in...
|
||||
*/
|
||||
memcpy(s, contents, end - contents);
|
||||
s[end - contents] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
s[0] = 0;
|
||||
}
|
||||
|
||||
/* If we only wanted the first occurence of this header, we're done. */
|
||||
if (!all_p) break;
|
||||
}
|
||||
}
|
||||
/* If we only wanted the first occurence of this header, we're done. */
|
||||
if (!all_p) break;
|
||||
}
|
||||
}
|
||||
|
||||
if (result && !*result) /* empty string */
|
||||
{
|
||||
PR_Free(result);
|
||||
return 0;
|
||||
}
|
||||
{
|
||||
PR_Free(result);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
char *
|
||||
MimeHeaders_get_parameter (const char *header_value, const char *parm_name,
|
||||
MimeHeaders_get_parameter (const char *header_value, const char *parm_name,
|
||||
char **charset, char **language)
|
||||
{
|
||||
if (!header_value || !parm_name || !*header_value || !*parm_name)
|
||||
return nsnull;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr <nsIMIMEHeaderParam> mimehdrpar =
|
||||
nsCOMPtr <nsIMIMEHeaderParam> mimehdrpar =
|
||||
do_GetService(NS_MIMEHEADERPARAM_CONTRACTID, &rv);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return nsnull;
|
||||
|
||||
nsCString result;
|
||||
rv = mimehdrpar->GetParameterInternal(header_value, parm_name, charset,
|
||||
rv = mimehdrpar->GetParameterInternal(header_value, parm_name, charset,
|
||||
language, getter_Copies(result));
|
||||
return NS_SUCCEEDED(rv) ? PL_strdup(result.get()) : nsnull;
|
||||
return NS_SUCCEEDED(rv) ? PL_strdup(result.get()) : nsnull;
|
||||
}
|
||||
|
||||
#define MimeHeaders_write(OPT,DATA,LENGTH) \
|
||||
MimeOptions_write((OPT), (DATA), (LENGTH), PR_TRUE);
|
||||
MimeOptions_write((OPT), (DATA), (LENGTH), PR_TRUE);
|
||||
|
||||
|
||||
#define MimeHeaders_grow_obuffer(hdrs, desired_size) \
|
||||
((((long) (desired_size)) >= ((long) (hdrs)->obuffer_size)) ? \
|
||||
mime_GrowBuffer ((desired_size), sizeof(char), 255, \
|
||||
&(hdrs)->obuffer, &(hdrs)->obuffer_size) \
|
||||
&(hdrs)->obuffer, &(hdrs)->obuffer_size) \
|
||||
: 0)
|
||||
|
||||
int
|
||||
@@ -513,7 +512,7 @@ MimeHeaders_write_all_headers (MimeHeaders *hdrs, MimeDisplayOptions *opt, PRBoo
|
||||
PRBool wrote_any_p = PR_FALSE;
|
||||
|
||||
NS_ASSERTION(hdrs, "1.1 <rhp@netscape.com> 19 Mar 1999 12:00");
|
||||
if (!hdrs)
|
||||
if (!hdrs)
|
||||
return -1;
|
||||
|
||||
/* One shouldn't be trying to read headers when one hasn't finished
|
||||
@@ -552,7 +551,7 @@ MimeHeaders_write_all_headers (MimeHeaders *hdrs, MimeDisplayOptions *opt, PRBoo
|
||||
: hdrs->heads[i+1]);
|
||||
char *colon, *ocolon;
|
||||
char *contents = end;
|
||||
|
||||
|
||||
/* Hack for BSD Mailbox delimiter. */
|
||||
if (i == 0 && head[0] == 'F' && !strncmp(head, "From ", 5))
|
||||
{
|
||||
@@ -566,23 +565,23 @@ MimeHeaders_write_all_headers (MimeHeaders *hdrs, MimeDisplayOptions *opt, PRBoo
|
||||
/* Find the colon. */
|
||||
for (colon = head; colon < end && *colon != ':'; colon++)
|
||||
;
|
||||
|
||||
|
||||
/* Back up over whitespace before the colon. */
|
||||
ocolon = colon;
|
||||
for (; colon > head && nsCRT::IsAsciiSpace(colon[-1]); colon--)
|
||||
for (; colon > head && IS_SPACE(colon[-1]); colon--)
|
||||
;
|
||||
|
||||
|
||||
contents = ocolon + 1;
|
||||
}
|
||||
|
||||
|
||||
/* Skip over whitespace after colon. */
|
||||
while (contents < end && nsCRT::IsAsciiSpace(*contents))
|
||||
while (contents < end && IS_SPACE(*contents))
|
||||
contents++;
|
||||
|
||||
|
||||
/* Take off trailing whitespace... */
|
||||
while (end > contents && nsCRT::IsAsciiSpace(end[-1]))
|
||||
while (end > contents && IS_SPACE(end[-1]))
|
||||
end--;
|
||||
|
||||
|
||||
nsCAutoString name(Substring(head, colon));
|
||||
nsCAutoString hdr_value;
|
||||
|
||||
@@ -590,7 +589,7 @@ MimeHeaders_write_all_headers (MimeHeaders *hdrs, MimeDisplayOptions *opt, PRBoo
|
||||
{
|
||||
hdr_value = Substring(contents, end);
|
||||
}
|
||||
|
||||
|
||||
MimeHeaders_convert_header_value(opt, hdr_value);
|
||||
// if we're saving as html, we need to convert headers from utf8 to message charset, if any
|
||||
if (opt->format_out == nsMimeOutput::nsMimeMessageSaveAs && charset)
|
||||
@@ -607,9 +606,9 @@ MimeHeaders_write_all_headers (MimeHeaders *hdrs, MimeDisplayOptions *opt, PRBoo
|
||||
status = mimeEmitterAddAttachmentField(opt, name.get(), hdr_value.get());
|
||||
else
|
||||
status = mimeEmitterAddHeaderField(opt, name.get(), hdr_value.get());
|
||||
|
||||
|
||||
if (status < 0) return status;
|
||||
if (!wrote_any_p)
|
||||
if (!wrote_any_p)
|
||||
wrote_any_p = (status > 0);
|
||||
}
|
||||
mimeEmitterAddAllHeaders(opt, hdrs->all_headers, hdrs->all_headers_fp);
|
||||
@@ -629,39 +628,39 @@ HG99401
|
||||
extern "C" char *
|
||||
MIME_StripContinuations(char *original)
|
||||
{
|
||||
char *p1, *p2;
|
||||
char *p1, *p2;
|
||||
|
||||
/* If we were given a null string, return it as is */
|
||||
if (!original) return NULL;
|
||||
/* If we were given a null string, return it as is */
|
||||
if (!original) return NULL;
|
||||
|
||||
/* Start source and dest pointers at the beginning */
|
||||
p1 = p2 = original;
|
||||
/* Start source and dest pointers at the beginning */
|
||||
p1 = p2 = original;
|
||||
|
||||
while(*p2)
|
||||
{
|
||||
/* p2 runs ahead at (CR and/or LF) */
|
||||
if ((p2[0] == '\r') || (p2[0] == '\n'))
|
||||
{
|
||||
while(*p2)
|
||||
{
|
||||
/* p2 runs ahead at (CR and/or LF) */
|
||||
if ((p2[0] == '\r') || (p2[0] == '\n'))
|
||||
{
|
||||
p2++;
|
||||
} else {
|
||||
} else {
|
||||
*p1++ = *p2++;
|
||||
}
|
||||
}
|
||||
*p1 = '\0';
|
||||
}
|
||||
*p1 = '\0';
|
||||
|
||||
return original;
|
||||
return original;
|
||||
}
|
||||
|
||||
extern PRInt16 INTL_DefaultMailToWinCharSetID(PRInt16 csid);
|
||||
|
||||
/* Given text purporting to be a qtext header value, strip backslashes that
|
||||
may be escaping other chars in the string. */
|
||||
may be escaping other chars in the string. */
|
||||
char *
|
||||
mime_decode_filename(char *name, const char *charset,
|
||||
MimeDisplayOptions *opt)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr <nsIMIMEHeaderParam> mimehdrpar =
|
||||
nsCOMPtr <nsIMIMEHeaderParam> mimehdrpar =
|
||||
do_GetService(NS_MIMEHEADERPARAM_CONTRACTID, &rv);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
@@ -670,7 +669,7 @@ mime_decode_filename(char *name, const char *charset,
|
||||
rv = mimehdrpar->DecodeParameter(nsDependentCString(name), charset,
|
||||
opt->default_charset,
|
||||
opt->override_charset, result);
|
||||
return NS_SUCCEEDED(rv) ? PL_strdup(result.get()) : nsnull;
|
||||
return NS_SUCCEEDED(rv) ? PL_strdup(result.get()) : nsnull;
|
||||
}
|
||||
|
||||
/* Pull the name out of some header or another. Order is:
|
||||
@@ -706,7 +705,7 @@ MimeHeaders_get_name(MimeHeaders *hdrs, MimeDisplayOptions *opt)
|
||||
|
||||
if (! name)
|
||||
name = MimeHeaders_get (hdrs, HEADER_CONTENT_NAME, PR_FALSE, PR_FALSE);
|
||||
|
||||
|
||||
if (! name)
|
||||
name = MimeHeaders_get (hdrs, HEADER_X_SUN_DATA_NAME, PR_FALSE, PR_FALSE);
|
||||
|
||||
@@ -714,8 +713,8 @@ MimeHeaders_get_name(MimeHeaders *hdrs, MimeDisplayOptions *opt)
|
||||
{
|
||||
/* First remove continuation delimiters (CR+LF+space), then
|
||||
remove escape ('\\') characters, then attempt to decode
|
||||
mime-2 encoded-words. The latter two are done in
|
||||
mime_decode_filename.
|
||||
mime-2 encoded-words. The latter two are done in
|
||||
mime_decode_filename.
|
||||
*/
|
||||
MIME_StripContinuations(name);
|
||||
|
||||
@@ -756,9 +755,9 @@ MimeHeaders_do_unix_display_hook_hack(MimeHeaders *hdrs)
|
||||
if (!cmd)
|
||||
cmd = "";
|
||||
}
|
||||
|
||||
|
||||
/* Invoke "cmd" at the end of a pipe, and give it the headers on stdin.
|
||||
The command is expected to be safe from hostile input!!
|
||||
The command is expected to be safe from hostile input!!
|
||||
*/
|
||||
if (cmd && *cmd)
|
||||
{
|
||||
@@ -794,54 +793,54 @@ MimeHeaders_compact (MimeHeaders *hdrs)
|
||||
*/
|
||||
int
|
||||
MimeHeaders_write_raw_headers (MimeHeaders *hdrs, MimeDisplayOptions *opt,
|
||||
PRBool dont_write_content_type)
|
||||
PRBool dont_write_content_type)
|
||||
{
|
||||
int status;
|
||||
|
||||
if (hdrs && !hdrs->done_p)
|
||||
{
|
||||
hdrs->done_p = PR_TRUE;
|
||||
status = MimeHeaders_build_heads_list(hdrs);
|
||||
if (status < 0) return 0;
|
||||
}
|
||||
{
|
||||
hdrs->done_p = PR_TRUE;
|
||||
status = MimeHeaders_build_heads_list(hdrs);
|
||||
if (status < 0) return 0;
|
||||
}
|
||||
|
||||
if (!dont_write_content_type)
|
||||
{
|
||||
char nl[] = MSG_LINEBREAK;
|
||||
if (hdrs)
|
||||
{
|
||||
status = MimeHeaders_write(opt, hdrs->all_headers,
|
||||
hdrs->all_headers_fp);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
status = MimeHeaders_write(opt, nl, strlen(nl));
|
||||
if (status < 0) return status;
|
||||
}
|
||||
{
|
||||
char nl[] = MSG_LINEBREAK;
|
||||
if (hdrs)
|
||||
{
|
||||
status = MimeHeaders_write(opt, hdrs->all_headers,
|
||||
hdrs->all_headers_fp);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
status = MimeHeaders_write(opt, nl, strlen(nl));
|
||||
if (status < 0) return status;
|
||||
}
|
||||
else if (hdrs)
|
||||
{
|
||||
PRInt32 i;
|
||||
for (i = 0; i < hdrs->heads_size; i++)
|
||||
{
|
||||
char *head = hdrs->heads[i];
|
||||
char *end = (i == hdrs->heads_size-1
|
||||
? hdrs->all_headers + hdrs->all_headers_fp
|
||||
: hdrs->heads[i+1]);
|
||||
{
|
||||
PRInt32 i;
|
||||
for (i = 0; i < hdrs->heads_size; i++)
|
||||
{
|
||||
char *head = hdrs->heads[i];
|
||||
char *end = (i == hdrs->heads_size-1
|
||||
? hdrs->all_headers + hdrs->all_headers_fp
|
||||
: hdrs->heads[i+1]);
|
||||
|
||||
NS_ASSERTION(head, "1.22 <rhp@netscape.com> 22 Aug 1999 08:48");
|
||||
if (!head) continue;
|
||||
NS_ASSERTION(head, "1.22 <rhp@netscape.com> 22 Aug 1999 08:48");
|
||||
if (!head) continue;
|
||||
|
||||
/* Don't write out any Content- header. */
|
||||
if (!nsCRT::strncasecmp(head, "Content-", 8))
|
||||
continue;
|
||||
/* Don't write out any Content- header. */
|
||||
if (!PL_strncasecmp(head, "Content-", 8))
|
||||
continue;
|
||||
|
||||
/* Write out this (possibly multi-line) header. */
|
||||
status = MimeHeaders_write(opt, head, end - head);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
}
|
||||
/* Write out this (possibly multi-line) header. */
|
||||
status = MimeHeaders_write(opt, head, end - head);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
}
|
||||
|
||||
if (hdrs)
|
||||
MimeHeaders_compact (hdrs);
|
||||
MimeHeaders_compact (hdrs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -42,12 +42,11 @@
|
||||
#include "prlog.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsMimeStringResources.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsEscape.h"
|
||||
|
||||
#define MIME_SUPERCLASS mimeLeafClass
|
||||
MimeDefClass(MimeInlineImage, MimeInlineImageClass,
|
||||
mimeInlineImageClass, &MIME_SUPERCLASS);
|
||||
mimeInlineImageClass, &MIME_SUPERCLASS);
|
||||
|
||||
static int MimeInlineImage_initialize (MimeObject *);
|
||||
static void MimeInlineImage_finalize (MimeObject *);
|
||||
@@ -114,7 +113,7 @@ MimeInlineImage_parse_begin (MimeObject *obj)
|
||||
|
||||
part = mime_part_address(obj);
|
||||
if (!part) return MIME_OUT_OF_MEMORY;
|
||||
|
||||
|
||||
char *no_part_url = nsnull;
|
||||
if (obj->options->part_to_load && obj->options->format_out == nsMimeOutput::nsMimeMessageBodyDisplay)
|
||||
no_part_url = mime_get_base_url(obj->options->url);
|
||||
@@ -129,15 +128,15 @@ MimeInlineImage_parse_begin (MimeObject *obj)
|
||||
|
||||
if (!image_url)
|
||||
{
|
||||
PR_Free(part);
|
||||
PR_Free(part);
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
PR_Free(part);
|
||||
|
||||
|
||||
ct = obj->content_type;
|
||||
if (!ct) ct = IMAGE_GIF; /* Can't happen? Close enough. */
|
||||
|
||||
// Fill in content type and attachment name here.
|
||||
// Fill in content type and attachment name here.
|
||||
nsCAutoString url_with_filename(image_url);
|
||||
url_with_filename += "&type=";
|
||||
url_with_filename += ct;
|
||||
@@ -148,14 +147,14 @@ MimeInlineImage_parse_begin (MimeObject *obj)
|
||||
if (!escapedName) return MIME_OUT_OF_MEMORY;
|
||||
url_with_filename += "&filename=";
|
||||
url_with_filename += escapedName;
|
||||
nsCRT::free(escapedName);
|
||||
NS_Free(escapedName);
|
||||
PR_Free(filename);
|
||||
}
|
||||
|
||||
// We need to separate images with HR's...
|
||||
MimeObject_write_separator(obj);
|
||||
|
||||
img->image_data =
|
||||
img->image_data =
|
||||
obj->options->image_begin(url_with_filename.get(), ct, obj->options->stream_closure);
|
||||
PR_Free(image_url);
|
||||
|
||||
@@ -169,7 +168,7 @@ MimeInlineImage_parse_begin (MimeObject *obj)
|
||||
if (status < 0) return status;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// Now we are going to see if we should set the content type in the
|
||||
// URI for the url being run...
|
||||
//
|
||||
@@ -198,11 +197,11 @@ MimeInlineImage_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
if (status < 0) abort_p = PR_TRUE;
|
||||
|
||||
if (img->image_data)
|
||||
{
|
||||
obj->options->image_end(img->image_data,
|
||||
(status < 0 ? status : (abort_p ? -1 : 0)));
|
||||
img->image_data = 0;
|
||||
}
|
||||
{
|
||||
obj->options->image_end(img->image_data,
|
||||
(status < 0 ? status : (abort_p ? -1 : 0)));
|
||||
img->image_data = 0;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -212,55 +211,55 @@ static int
|
||||
MimeInlineImage_parse_decoded_buffer (const char *buf, PRInt32 size, MimeObject *obj)
|
||||
{
|
||||
/* This is called (by MimeLeafClass->parse_buffer) with blocks of data
|
||||
that have already been base64-decoded. Pass this raw image data
|
||||
along to the backend-specific image display code.
|
||||
that have already been base64-decoded. Pass this raw image data
|
||||
along to the backend-specific image display code.
|
||||
*/
|
||||
MimeInlineImage *img = (MimeInlineImage *) obj;
|
||||
int status;
|
||||
|
||||
if (obj->output_p &&
|
||||
obj->options &&
|
||||
!obj->options->write_html_p)
|
||||
{
|
||||
/* in this case, we just want the raw data...
|
||||
Make the stream, if it's not made, and dump the data out.
|
||||
*/
|
||||
obj->options &&
|
||||
!obj->options->write_html_p)
|
||||
{
|
||||
/* in this case, we just want the raw data...
|
||||
Make the stream, if it's not made, and dump the data out.
|
||||
*/
|
||||
|
||||
if (!obj->options->state->first_data_written_p)
|
||||
{
|
||||
status = MimeObject_output_init(obj, 0);
|
||||
if (status < 0) return status;
|
||||
NS_ASSERTION(obj->options->state->first_data_written_p, "1.1 <rhp@netscape.com> 19 Mar 1999 12:00");
|
||||
}
|
||||
|
||||
return MimeObject_write(obj, buf, size, PR_TRUE);
|
||||
}
|
||||
if (!obj->options->state->first_data_written_p)
|
||||
{
|
||||
status = MimeObject_output_init(obj, 0);
|
||||
if (status < 0) return status;
|
||||
NS_ASSERTION(obj->options->state->first_data_written_p, "1.1 <rhp@netscape.com> 19 Mar 1999 12:00");
|
||||
}
|
||||
|
||||
return MimeObject_write(obj, buf, size, PR_TRUE);
|
||||
}
|
||||
|
||||
|
||||
if (!obj->options ||
|
||||
!obj->options->image_write_buffer)
|
||||
return 0;
|
||||
!obj->options->image_write_buffer)
|
||||
return 0;
|
||||
|
||||
/* If we don't have any image data, the image_end method must have already
|
||||
been called, so don't call image_write_buffer again. */
|
||||
been called, so don't call image_write_buffer again. */
|
||||
if (!img->image_data) return 0;
|
||||
|
||||
/* Hand this data off to the backend-specific image display stream.
|
||||
*/
|
||||
status = obj->options->image_write_buffer (buf, size, img->image_data);
|
||||
|
||||
|
||||
/* If the image display stream fails, then close the stream - but do not
|
||||
return the failure status, and do not give up on parsing this object.
|
||||
Just because the image data was corrupt doesn't mean we need to give up
|
||||
on the whole document; we can continue by just skipping over the rest of
|
||||
this part, and letting our parent continue.
|
||||
return the failure status, and do not give up on parsing this object.
|
||||
Just because the image data was corrupt doesn't mean we need to give up
|
||||
on the whole document; we can continue by just skipping over the rest of
|
||||
this part, and letting our parent continue.
|
||||
*/
|
||||
if (status < 0)
|
||||
{
|
||||
obj->options->image_end (img->image_data, status);
|
||||
img->image_data = 0;
|
||||
status = 0;
|
||||
}
|
||||
{
|
||||
obj->options->image_end (img->image_data, status);
|
||||
img->image_data = 0;
|
||||
status = 0;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
#include "plstr.h"
|
||||
#include "prlog.h"
|
||||
#include "nsMimeStringResources.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
#define MIME_SUPERCLASS mimeObjectClass
|
||||
MimeDefClass(MimeLeaf, MimeLeafClass, mimeLeafClass, &MIME_SUPERCLASS);
|
||||
@@ -55,7 +54,7 @@ static int MimeLeaf_parse_line (const char *, PRInt32, MimeObject *);
|
||||
static int MimeLeaf_close_decoder (MimeObject *);
|
||||
static int MimeLeaf_parse_eof (MimeObject *, PRBool);
|
||||
static PRBool MimeLeaf_displayable_inline_p (MimeObjectClass *clazz,
|
||||
MimeHeaders *hdrs);
|
||||
MimeHeaders *hdrs);
|
||||
|
||||
static int
|
||||
MimeLeafClassInitialize(MimeLeafClass *clazz)
|
||||
@@ -72,12 +71,12 @@ MimeLeafClassInitialize(MimeLeafClass *clazz)
|
||||
clazz->close_decoder = MimeLeaf_close_decoder;
|
||||
|
||||
/* Default `parse_buffer' method is one which line-buffers the now-decoded
|
||||
data and passes it on to `parse_line'. (We snarf the implementation of
|
||||
this method from our superclass's implementation of `parse_buffer', which
|
||||
inherited it from MimeObject.)
|
||||
data and passes it on to `parse_line'. (We snarf the implementation of
|
||||
this method from our superclass's implementation of `parse_buffer', which
|
||||
inherited it from MimeObject.)
|
||||
*/
|
||||
clazz->parse_decoded_buffer =
|
||||
((MimeObjectClass*)&MIME_SUPERCLASS)->parse_buffer;
|
||||
((MimeObjectClass*)&MIME_SUPERCLASS)->parse_buffer;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -100,12 +99,12 @@ MimeLeaf_finalize (MimeObject *object)
|
||||
object->clazz->parse_eof (object, PR_FALSE);
|
||||
|
||||
/* Free the decoder data, if it's still around. It was probably freed
|
||||
in MimeLeaf_parse_eof(), but just in case... */
|
||||
in MimeLeaf_parse_eof(), but just in case... */
|
||||
if (leaf->decoder_data)
|
||||
{
|
||||
MimeDecoderDestroy(leaf->decoder_data, PR_TRUE);
|
||||
leaf->decoder_data = 0;
|
||||
}
|
||||
{
|
||||
MimeDecoderDestroy(leaf->decoder_data, PR_TRUE);
|
||||
leaf->decoder_data = 0;
|
||||
}
|
||||
|
||||
((MimeObjectClass*)&MIME_SUPERCLASS)->finalize (object);
|
||||
}
|
||||
@@ -120,34 +119,34 @@ MimeLeaf_parse_begin (MimeObject *obj)
|
||||
/* Initialize a decoder if necessary.
|
||||
*/
|
||||
if (!obj->encoding)
|
||||
;
|
||||
else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_BASE64))
|
||||
fn = &MimeB64DecoderInit;
|
||||
else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_QUOTED_PRINTABLE))
|
||||
leaf->decoder_data =
|
||||
;
|
||||
else if (!PL_strcasecmp(obj->encoding, ENCODING_BASE64))
|
||||
fn = &MimeB64DecoderInit;
|
||||
else if (!PL_strcasecmp(obj->encoding, ENCODING_QUOTED_PRINTABLE))
|
||||
leaf->decoder_data =
|
||||
MimeQPDecoderInit(((nsresult (*) (const char *, PRInt32, void *))
|
||||
((MimeLeafClass *)obj->clazz)->parse_decoded_buffer),
|
||||
obj, obj);
|
||||
else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE) ||
|
||||
!nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE2) ||
|
||||
!nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE3) ||
|
||||
!nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE4))
|
||||
fn = &MimeUUDecoderInit;
|
||||
else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_YENCODE))
|
||||
else if (!PL_strcasecmp(obj->encoding, ENCODING_UUENCODE) ||
|
||||
!PL_strcasecmp(obj->encoding, ENCODING_UUENCODE2) ||
|
||||
!PL_strcasecmp(obj->encoding, ENCODING_UUENCODE3) ||
|
||||
!PL_strcasecmp(obj->encoding, ENCODING_UUENCODE4))
|
||||
fn = &MimeUUDecoderInit;
|
||||
else if (!PL_strcasecmp(obj->encoding, ENCODING_YENCODE))
|
||||
fn = &MimeYDecoderInit;
|
||||
|
||||
if (fn)
|
||||
{
|
||||
leaf->decoder_data =
|
||||
fn (/* The (nsresult (*) ...) cast is to turn the `void' argument
|
||||
into `MimeObject'. */
|
||||
((nsresult (*) (const char *, PRInt32, void *))
|
||||
((MimeLeafClass *)obj->clazz)->parse_decoded_buffer),
|
||||
obj);
|
||||
{
|
||||
leaf->decoder_data =
|
||||
fn (/* The (nsresult (*) ...) cast is to turn the `void' argument
|
||||
into `MimeObject'. */
|
||||
((nsresult (*) (const char *, PRInt32, void *))
|
||||
((MimeLeafClass *)obj->clazz)->parse_decoded_buffer),
|
||||
obj);
|
||||
|
||||
if (!leaf->decoder_data)
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
if (!leaf->decoder_data)
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_begin(obj);
|
||||
}
|
||||
@@ -164,18 +163,18 @@ MimeLeaf_parse_buffer (const char *buffer, PRInt32 size, MimeObject *obj)
|
||||
/* If we're not supposed to write this object, bug out now.
|
||||
*/
|
||||
if (!obj->output_p ||
|
||||
!obj->options ||
|
||||
!obj->options->output_fn)
|
||||
return 0;
|
||||
!obj->options ||
|
||||
!obj->options->output_fn)
|
||||
return 0;
|
||||
|
||||
if (leaf->decoder_data &&
|
||||
obj->options &&
|
||||
obj->options->format_out != nsMimeOutput::nsMimeMessageDecrypt
|
||||
&& obj->options->format_out != nsMimeOutput::nsMimeMessageAttach)
|
||||
return MimeDecoderWrite (leaf->decoder_data, buffer, size);
|
||||
return MimeDecoderWrite (leaf->decoder_data, buffer, size);
|
||||
else
|
||||
return ((MimeLeafClass *)obj->clazz)->parse_decoded_buffer (buffer, size,
|
||||
obj);
|
||||
return ((MimeLeafClass *)obj->clazz)->parse_decoded_buffer (buffer, size,
|
||||
obj);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -210,7 +209,7 @@ MimeLeaf_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
if (obj->closed_p) return 0;
|
||||
|
||||
/* Close off the decoder, to cause it to give up any buffered data that
|
||||
it is still holding.
|
||||
it is still holding.
|
||||
*/
|
||||
if (leaf->decoder_data)
|
||||
{
|
||||
@@ -219,7 +218,7 @@ MimeLeaf_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
}
|
||||
|
||||
/* Now run the superclass's parse_eof, which will force out the line
|
||||
buffer (which we may have just repopulated, above.)
|
||||
buffer (which we may have just repopulated, above.)
|
||||
*/
|
||||
return ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_eof (obj, abort_p);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
#include "nsMimeStringResources.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "mimemoz2.h" // for prefs
|
||||
#include "nsCRT.h"
|
||||
|
||||
extern "C" MimeObjectClass mimeMultipartRelatedClass;
|
||||
|
||||
@@ -132,7 +131,7 @@ MimeMultipartAlternative_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
|
||||
/* If there's a cached part we haven't written out yet, do it now.
|
||||
*/
|
||||
if (malt->buffered_hdrs && !abort_p &&
|
||||
if (malt->buffered_hdrs && !abort_p &&
|
||||
obj->options->format_out != nsMimeOutput::nsMimeMessageAttach)
|
||||
{
|
||||
status = MimeMultipartAlternative_display_cached_part(obj);
|
||||
@@ -240,16 +239,16 @@ MimeMultipartAlternative_display_part_p(MimeObject *self,
|
||||
*/
|
||||
|
||||
// prefer_plaintext pref
|
||||
nsIPrefBranch *prefBranch = GetPrefBranch(self->options);
|
||||
nsIPrefBranch *prefBranch = GetPrefBranch(self->options);
|
||||
PRBool prefer_plaintext = PR_FALSE;
|
||||
if (prefBranch)
|
||||
prefBranch->GetBoolPref("mailnews.display.prefer_plaintext",
|
||||
&prefer_plaintext);
|
||||
if (prefer_plaintext
|
||||
&& self->options->format_out != nsMimeOutput::nsMimeMessageSaveAs
|
||||
&& (!nsCRT::strncasecmp(ct, "text/html", 9) ||
|
||||
!nsCRT::strncasecmp(ct, "text/enriched", 13) ||
|
||||
!nsCRT::strncasecmp(ct, "text/richtext", 13))
|
||||
&& (!PL_strncasecmp(ct, "text/html", 9) ||
|
||||
!PL_strncasecmp(ct, "text/enriched", 13) ||
|
||||
!PL_strncasecmp(ct, "text/richtext", 13))
|
||||
)
|
||||
// if the user prefers plaintext and this is the "rich" (e.g. HTML) part...
|
||||
{
|
||||
@@ -270,7 +269,7 @@ MimeMultipartAlternative_display_part_p(MimeObject *self,
|
||||
return result;
|
||||
}
|
||||
|
||||
static int
|
||||
static int
|
||||
MimeMultipartAlternative_discard_cached_part(MimeObject *obj)
|
||||
{
|
||||
MimeMultipartAlternative *malt = (MimeMultipartAlternative *) obj;
|
||||
@@ -286,7 +285,7 @@ MimeMultipartAlternative_discard_cached_part(MimeObject *obj)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
static int
|
||||
MimeMultipartAlternative_display_cached_part(MimeObject *obj)
|
||||
{
|
||||
MimeMultipartAlternative *malt = (MimeMultipartAlternative *) obj;
|
||||
|
||||
@@ -42,15 +42,14 @@
|
||||
#include "nsMimeStringResources.h"
|
||||
#include "mimemoz2.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
#define MIME_SUPERCLASS mimeMultipartClass
|
||||
MimeDefClass(MimeMultipartAppleDouble, MimeMultipartAppleDoubleClass,
|
||||
mimeMultipartAppleDoubleClass, &MIME_SUPERCLASS);
|
||||
mimeMultipartAppleDoubleClass, &MIME_SUPERCLASS);
|
||||
|
||||
static int MimeMultipartAppleDouble_parse_begin (MimeObject *);
|
||||
static PRBool MimeMultipartAppleDouble_output_child_p(MimeObject *,
|
||||
MimeObject *);
|
||||
MimeObject *);
|
||||
|
||||
static int
|
||||
MimeMultipartAppleDoubleClassInitialize(MimeMultipartAppleDoubleClass *clazz)
|
||||
@@ -68,7 +67,7 @@ static int
|
||||
MimeMultipartAppleDouble_parse_begin (MimeObject *obj)
|
||||
{
|
||||
/* #### This method is identical to MimeExternalObject_parse_begin
|
||||
which kinda s#$%s...
|
||||
which kinda s#$%s...
|
||||
*/
|
||||
int status;
|
||||
|
||||
@@ -76,23 +75,23 @@ MimeMultipartAppleDouble_parse_begin (MimeObject *obj)
|
||||
if (status < 0) return status;
|
||||
|
||||
/* If we're writing this object, and we're doing it in raw form, then
|
||||
now is the time to inform the backend what the type of this data is.
|
||||
now is the time to inform the backend what the type of this data is.
|
||||
*/
|
||||
if (obj->output_p &&
|
||||
obj->options &&
|
||||
!obj->options->write_html_p &&
|
||||
!obj->options->state->first_data_written_p)
|
||||
{
|
||||
status = MimeObject_output_init(obj, 0);
|
||||
if (status < 0) return status;
|
||||
NS_ASSERTION(obj->options->state->first_data_written_p, "first data not written");
|
||||
}
|
||||
obj->options &&
|
||||
!obj->options->write_html_p &&
|
||||
!obj->options->state->first_data_written_p)
|
||||
{
|
||||
status = MimeObject_output_init(obj, 0);
|
||||
if (status < 0) return status;
|
||||
NS_ASSERTION(obj->options->state->first_data_written_p, "first data not written");
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
if (obj->options && obj->options->state)
|
||||
if (obj->options && obj->options->state)
|
||||
{
|
||||
// obj->options->state->separator_suppressed_p = PR_TRUE;
|
||||
goto done;
|
||||
// obj->options->state->separator_suppressed_p = PR_TRUE;
|
||||
goto done;
|
||||
}
|
||||
/*
|
||||
* It would be nice to not showing the resource fork links
|
||||
@@ -102,76 +101,75 @@ MimeMultipartAppleDouble_parse_begin (MimeObject *obj)
|
||||
*/
|
||||
#endif
|
||||
/* If we're writing this object as HTML, then emit a link for the
|
||||
multipart/appledouble part (both links) that looks just like the
|
||||
links that MimeExternalObject emits for external leaf parts.
|
||||
multipart/appledouble part (both links) that looks just like the
|
||||
links that MimeExternalObject emits for external leaf parts.
|
||||
*/
|
||||
if (obj->options &&
|
||||
obj->output_p &&
|
||||
obj->options->write_html_p &&
|
||||
obj->options->output_fn)
|
||||
{
|
||||
char *id = 0;
|
||||
char *id_url = 0;
|
||||
char *id_imap = 0;
|
||||
obj->output_p &&
|
||||
obj->options->write_html_p &&
|
||||
obj->options->output_fn)
|
||||
{
|
||||
char *id = 0;
|
||||
char *id_url = 0;
|
||||
char *id_imap = 0;
|
||||
|
||||
id = mime_part_address (obj);
|
||||
if (! id) return MIME_OUT_OF_MEMORY;
|
||||
if (obj->options->missing_parts)
|
||||
id_imap = mime_imap_part_address (obj);
|
||||
id = mime_part_address (obj);
|
||||
if (! id) return MIME_OUT_OF_MEMORY;
|
||||
if (obj->options->missing_parts)
|
||||
id_imap = mime_imap_part_address (obj);
|
||||
|
||||
if (obj->options && obj->options->url)
|
||||
{
|
||||
const char *url = obj->options->url;
|
||||
if (id_imap && id)
|
||||
{
|
||||
/* if this is an IMAP part. */
|
||||
id_url = mime_set_url_imap_part(url, id_imap, id);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is just a normal MIME part as usual. */
|
||||
id_url = mime_set_url_part(url, id, PR_TRUE);
|
||||
}
|
||||
if (!id_url)
|
||||
{
|
||||
PR_Free(id);
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
{
|
||||
const char *url = obj->options->url;
|
||||
if (id_imap && id)
|
||||
{
|
||||
/* if this is an IMAP part. */
|
||||
id_url = mime_set_url_imap_part(url, id_imap, id);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is just a normal MIME part as usual. */
|
||||
id_url = mime_set_url_part(url, id, PR_TRUE);
|
||||
}
|
||||
if (!id_url)
|
||||
{
|
||||
PR_Free(id);
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
/**********************8
|
||||
RICHIE SHERRY
|
||||
if (!nsCRT::strcmp (id, "0"))
|
||||
{
|
||||
PR_Free(id);
|
||||
id = MimeGetStringByID(MIME_MSG_ATTACHMENT);
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *p = "Part ";
|
||||
char *s = (char *)PR_MALLOC(nsCRT::strlen(p) + nsCRT::strlen(id) + 1);
|
||||
if (!s)
|
||||
{
|
||||
PR_Free(id);
|
||||
PR_Free(id_url);
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
PL_strcpy(s, p);
|
||||
PL_strcat(s, id);
|
||||
PR_Free(id);
|
||||
id = s;
|
||||
}
|
||||
/**********************
|
||||
if (!strcmp (id, "0"))
|
||||
{
|
||||
PR_Free(id);
|
||||
id = MimeGetStringByID(MIME_MSG_ATTACHMENT);
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *p = "Part ";
|
||||
char *s = (char *)PR_MALLOC(strlen(p) + strlen(id) + 1);
|
||||
if (!s)
|
||||
{
|
||||
PR_Free(id);
|
||||
PR_Free(id_url);
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
PL_strcpy(s, p);
|
||||
PL_strcat(s, id);
|
||||
PR_Free(id);
|
||||
id = s;
|
||||
}
|
||||
|
||||
if (all_headers_p &&
|
||||
// Don't bother showing all headers on this part if it's the only
|
||||
// part in the message: in that case, we've already shown these
|
||||
// headers.
|
||||
obj->options->state &&
|
||||
obj->options->state->root == obj->parent)
|
||||
all_headers_p = PR_FALSE;
|
||||
if (all_headers_p &&
|
||||
// Don't bother showing all headers on this part if it's the only
|
||||
// part in the message: in that case, we've already shown these
|
||||
// headers.
|
||||
obj->options->state &&
|
||||
obj->options->state->root == obj->parent)
|
||||
all_headers_p = PR_FALSE;
|
||||
|
||||
newopt.fancy_headers_p = PR_TRUE;
|
||||
newopt.headers = (all_headers_p ? MimeHeadersAll : MimeHeadersSome);
|
||||
newopt.fancy_headers_p = PR_TRUE;
|
||||
newopt.headers = (all_headers_p ? MimeHeadersAll : MimeHeadersSome);
|
||||
|
||||
//
|
||||
RICHIE SHERRY
|
||||
@@ -183,12 +181,12 @@ GOTTA STILL DO THIS FOR QUOTING!
|
||||
//
|
||||
*********************************************************************************/
|
||||
|
||||
// FAIL:
|
||||
PR_FREEIF(id);
|
||||
PR_FREEIF(id_url);
|
||||
PR_FREEIF(id_imap);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
// FAIL:
|
||||
PR_FREEIF(id);
|
||||
PR_FREEIF(id_url);
|
||||
PR_FREEIF(id_imap);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
done:
|
||||
@@ -203,12 +201,12 @@ MimeMultipartAppleDouble_output_child_p(MimeObject *obj, MimeObject *child)
|
||||
MimeContainer *cont = (MimeContainer *) obj;
|
||||
|
||||
/* If this is the first child, and it's an application/applefile, then
|
||||
don't emit a link for it. (There *should* be only two children, and
|
||||
the first one should always be an application/applefile.)
|
||||
don't emit a link for it. (There *should* be only two children, and
|
||||
the first one should always be an application/applefile.)
|
||||
*/
|
||||
|
||||
if (cont->nchildren >= 1 && cont->children[0] == child && child->content_type &&
|
||||
!nsCRT::strcasecmp(child->content_type, APPLICATION_APPLEFILE))
|
||||
!PL_strcasecmp(child->content_type, APPLICATION_APPLEFILE))
|
||||
{
|
||||
#ifdef XP_MACOSX
|
||||
if (obj->output_p && obj->options && obj->options->write_html_p) //output HTML
|
||||
@@ -218,6 +216,6 @@ MimeMultipartAppleDouble_output_child_p(MimeObject *obj, MimeObject *child)
|
||||
return PR_FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Contributor(s):
|
||||
* Kai Engert <kengert@redhat.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
@@ -114,7 +114,7 @@ typedef struct MimeMultCMSdata
|
||||
PRBool parent_is_encrypted_p;
|
||||
PRBool parent_holds_stamp_p;
|
||||
nsCOMPtr<nsIMsgSMIMEHeaderSink> smimeHeaderSink;
|
||||
|
||||
|
||||
MimeMultCMSdata()
|
||||
:hash_type(0),
|
||||
sender_addr(nsnull),
|
||||
@@ -125,7 +125,7 @@ typedef struct MimeMultCMSdata
|
||||
parent_holds_stamp_p(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
~MimeMultCMSdata()
|
||||
{
|
||||
PR_FREEIF(sender_addr);
|
||||
@@ -177,16 +177,16 @@ MimeMultCMS_init (MimeObject *obj)
|
||||
ct = 0;
|
||||
if (!micalg) return 0; /* #### bogus message? out of memory? */
|
||||
|
||||
if (!nsCRT::strcasecmp(micalg, PARAM_MICALG_MD5) ||
|
||||
!nsCRT::strcasecmp(micalg, PARAM_MICALG_MD5_2))
|
||||
if (!PL_strcasecmp(micalg, PARAM_MICALG_MD5) ||
|
||||
!PL_strcasecmp(micalg, PARAM_MICALG_MD5_2))
|
||||
hash_type = nsICryptoHash::MD5;
|
||||
else if (!nsCRT::strcasecmp(micalg, PARAM_MICALG_SHA1) ||
|
||||
!nsCRT::strcasecmp(micalg, PARAM_MICALG_SHA1_2) ||
|
||||
!nsCRT::strcasecmp(micalg, PARAM_MICALG_SHA1_3) ||
|
||||
!nsCRT::strcasecmp(micalg, PARAM_MICALG_SHA1_4) ||
|
||||
!nsCRT::strcasecmp(micalg, PARAM_MICALG_SHA1_5))
|
||||
else if (!PL_strcasecmp(micalg, PARAM_MICALG_SHA1) ||
|
||||
!PL_strcasecmp(micalg, PARAM_MICALG_SHA1_2) ||
|
||||
!PL_strcasecmp(micalg, PARAM_MICALG_SHA1_3) ||
|
||||
!PL_strcasecmp(micalg, PARAM_MICALG_SHA1_4) ||
|
||||
!PL_strcasecmp(micalg, PARAM_MICALG_SHA1_5))
|
||||
hash_type = nsICryptoHash::SHA1;
|
||||
else if (!nsCRT::strcasecmp(micalg, PARAM_MICALG_MD2))
|
||||
else if (!PL_strcasecmp(micalg, PARAM_MICALG_MD2))
|
||||
hash_type = nsICryptoHash::MD2;
|
||||
else
|
||||
hash_type = -1;
|
||||
@@ -255,7 +255,7 @@ MimeMultCMS_init (MimeObject *obj)
|
||||
//
|
||||
// If we do not find header=filter, we assume the result of the
|
||||
// processing will be shown in the UI.
|
||||
|
||||
|
||||
if (!strstr(urlSpec.get(), "?header=filter") &&
|
||||
!strstr(urlSpec.get(), "&header=filter")&&
|
||||
!strstr(urlSpec.get(), "?header=attach") &&
|
||||
@@ -304,11 +304,11 @@ MimeMultCMS_data_eof (void *crypto_closure, PRBool abort_p)
|
||||
nsCAutoString hashString;
|
||||
data->data_hash_context->Finish(PR_FALSE, hashString);
|
||||
PR_SetError(0, 0);
|
||||
|
||||
|
||||
data->item_len = hashString.Length();
|
||||
data->item_data = new unsigned char[data->item_len];
|
||||
if (!data->item_data) return MIME_OUT_OF_MEMORY;
|
||||
|
||||
|
||||
memcpy(data->item_data, hashString.get(), data->item_len);
|
||||
|
||||
// Release our reference to nsICryptoHash //
|
||||
@@ -340,8 +340,8 @@ MimeMultCMS_sig_init (void *crypto_closure,
|
||||
|
||||
/* Verify that the signature object is of the right type. */
|
||||
if (!ct || /* is not a signature type */
|
||||
(nsCRT::strcasecmp(ct, APPLICATION_XPKCS7_SIGNATURE) != 0
|
||||
&& nsCRT::strcasecmp(ct, APPLICATION_PKCS7_SIGNATURE) != 0)) {
|
||||
(PL_strcasecmp(ct, APPLICATION_XPKCS7_SIGNATURE) != 0
|
||||
&& PL_strcasecmp(ct, APPLICATION_PKCS7_SIGNATURE) != 0)) {
|
||||
status = -1; /* #### error msg about bogus message */
|
||||
}
|
||||
PR_FREEIF(ct);
|
||||
@@ -436,10 +436,10 @@ MimeMultCMS_generate (void *crypto_closure)
|
||||
{
|
||||
// We were not given all parts of the message.
|
||||
// We are therefore unable to verify correctness of the signature.
|
||||
|
||||
|
||||
if (data->smimeHeaderSink)
|
||||
data->smimeHeaderSink->SignedStatus(aRelativeNestLevel,
|
||||
nsICMSMessageErrors::VERIFY_NOT_YET_ATTEMPTED,
|
||||
data->smimeHeaderSink->SignedStatus(aRelativeNestLevel,
|
||||
nsICMSMessageErrors::VERIFY_NOT_YET_ATTEMPTED,
|
||||
nsnull);
|
||||
return nsnull;
|
||||
}
|
||||
@@ -453,20 +453,20 @@ MimeMultCMS_generate (void *crypto_closure)
|
||||
*/
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
|
||||
nsCString from_addr;
|
||||
nsCString from_name;
|
||||
nsCString sender_addr;
|
||||
nsCString sender_name;
|
||||
|
||||
MimeCMSGetFromSender(data->self,
|
||||
|
||||
MimeCMSGetFromSender(data->self,
|
||||
from_addr, from_name,
|
||||
sender_addr, sender_name);
|
||||
|
||||
MimeCMSRequestAsyncSignatureVerification(data->content_info,
|
||||
MimeCMSRequestAsyncSignatureVerification(data->content_info,
|
||||
from_addr.get(), from_name.get(),
|
||||
sender_addr.get(), sender_name.get(),
|
||||
data->smimeHeaderSink, aRelativeNestLevel,
|
||||
data->smimeHeaderSink, aRelativeNestLevel,
|
||||
data->item_data, data->item_len);
|
||||
|
||||
if (data->content_info)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -35,7 +35,7 @@
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK *****
|
||||
* This Original Code has been modified by IBM Corporation. Modifications made by IBM
|
||||
* This Original Code has been modified by IBM Corporation. Modifications made by IBM
|
||||
* described herein are Copyright (c) International Business Machines Corporation, 2000.
|
||||
* Modifications to Mozilla code or documentation identified per MPL Section 3.3
|
||||
*
|
||||
@@ -137,7 +137,6 @@
|
||||
#include "mimemoz2.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsCRT.h"
|
||||
#include "msgCore.h"
|
||||
#include "nsMimeStringResources.h"
|
||||
#include "nsMimeTypes.h"
|
||||
@@ -161,7 +160,7 @@ class MimeHashValue
|
||||
public:
|
||||
MimeHashValue(MimeObject *obj, char *url) {
|
||||
m_obj = obj;
|
||||
m_url = nsCRT::strdup(url);
|
||||
m_url = strdup(url);
|
||||
}
|
||||
virtual ~MimeHashValue() {
|
||||
if (m_url)
|
||||
@@ -205,9 +204,9 @@ MimeMultipartRelated_initialize(MimeObject* obj)
|
||||
return ((MimeObjectClass*)&MIME_SUPERCLASS)->initialize(obj);
|
||||
}
|
||||
|
||||
static PRIntn PR_CALLBACK
|
||||
mime_multipart_related_nukehash(PLHashEntry *table,
|
||||
PRIntn indx, void *arg)
|
||||
static PRIntn PR_CALLBACK
|
||||
mime_multipart_related_nukehash(PLHashEntry *table,
|
||||
PRIntn indx, void *arg)
|
||||
{
|
||||
if (table->key)
|
||||
PR_Free((char*) table->key);
|
||||
@@ -233,19 +232,19 @@ MimeMultipartRelated_finalize (MimeObject *obj)
|
||||
relobj->hash = NULL;
|
||||
}
|
||||
|
||||
if (relobj->input_file_stream)
|
||||
if (relobj->input_file_stream)
|
||||
{
|
||||
relobj->input_file_stream->Close();
|
||||
relobj->input_file_stream = nsnull;
|
||||
}
|
||||
|
||||
if (relobj->output_file_stream)
|
||||
if (relobj->output_file_stream)
|
||||
{
|
||||
relobj->output_file_stream->Close();
|
||||
relobj->output_file_stream = nsnull;
|
||||
}
|
||||
|
||||
if (relobj->file_buffer)
|
||||
if (relobj->file_buffer)
|
||||
{
|
||||
relobj->file_buffer->Remove(PR_FALSE);
|
||||
relobj->file_buffer = nsnull;
|
||||
@@ -257,7 +256,7 @@ MimeMultipartRelated_finalize (MimeObject *obj)
|
||||
#define ISHEX(c) ( ((c) >= '0' && (c) <= '9') || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F') )
|
||||
#define NONHEX(c) (!ISHEX(c))
|
||||
|
||||
extern "C" char *
|
||||
extern "C" char *
|
||||
escape_unescaped_percents(const char *incomingURL)
|
||||
{
|
||||
const char *inC;
|
||||
@@ -273,13 +272,13 @@ escape_unescaped_percents(const char *incomingURL)
|
||||
/* Check if either of the next two characters are non-hex. */
|
||||
if ( !*(inC+1) || NONHEX(*(inC+1)) || !*(inC+2) || NONHEX(*(inC+2)) )
|
||||
{
|
||||
/* Hex characters don't follow, escape the
|
||||
/* Hex characters don't follow, escape the
|
||||
percent char */
|
||||
*outC++ = '%'; *outC++ = '2'; *outC++ = '5';
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Hex characters follow, so assume the percent
|
||||
/* Hex characters follow, so assume the percent
|
||||
is escaping something else */
|
||||
*outC++ = *inC;
|
||||
}
|
||||
@@ -293,18 +292,17 @@ escape_unescaped_percents(const char *incomingURL)
|
||||
return result;
|
||||
}
|
||||
|
||||
/* This routine is only necessary because the mailbox URL fed to us
|
||||
/* This routine is only necessary because the mailbox URL fed to us
|
||||
by the winfe can contain spaces and '>'s in it. It's a hack. */
|
||||
static char *
|
||||
escape_for_mrel_subst(char *inURL)
|
||||
{
|
||||
char *output, *inC, *outC, *temp;
|
||||
|
||||
/* nsCRT::strlen asserts the presence of a string in inURL */
|
||||
int size = strlen(inURL) + 1;
|
||||
|
||||
for(inC = inURL; *inC; inC++)
|
||||
if ((*inC == ' ') || (*inC == '>'))
|
||||
if ((*inC == ' ') || (*inC == '>'))
|
||||
size += 2; /* space -> '%20', '>' -> '%3E', etc. */
|
||||
|
||||
output = (char *)PR_MALLOC(size);
|
||||
@@ -330,7 +328,7 @@ escape_for_mrel_subst(char *inURL)
|
||||
inC++;
|
||||
}
|
||||
*outC = '\0';
|
||||
|
||||
|
||||
temp = escape_unescaped_percents(output);
|
||||
if (temp)
|
||||
{
|
||||
@@ -375,18 +373,18 @@ MimeThisIsStartPart(MimeObject *obj, MimeObject* child)
|
||||
else
|
||||
{
|
||||
char *tmp = cst;
|
||||
if (*tmp == '<')
|
||||
if (*tmp == '<')
|
||||
{
|
||||
int length;
|
||||
tmp++;
|
||||
length = strlen(tmp);
|
||||
if (length > 0 && tmp[length - 1] == '>')
|
||||
if (length > 0 && tmp[length - 1] == '>')
|
||||
{
|
||||
tmp[length - 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
rval = (!nsCRT::strcmp(st, tmp));
|
||||
rval = (!strcmp(st, tmp));
|
||||
}
|
||||
|
||||
PR_FREEIF(st);
|
||||
@@ -413,16 +411,16 @@ MakeAbsoluteURL(char *base_url, char *relative_url)
|
||||
}
|
||||
|
||||
nsresult err = nsMimeNewURI(&base, base_url, nsnull);
|
||||
if (err != NS_OK)
|
||||
if (err != NS_OK)
|
||||
return nsnull;
|
||||
|
||||
nsCAutoString spec;
|
||||
|
||||
nsIURI *url = nsnull;
|
||||
err = nsMimeNewURI(&url, relative_url, base);
|
||||
if (err != NS_OK)
|
||||
if (err != NS_OK)
|
||||
goto done;
|
||||
|
||||
|
||||
err = url->GetSpec(spec);
|
||||
if (err)
|
||||
{
|
||||
@@ -430,7 +428,7 @@ MakeAbsoluteURL(char *base_url, char *relative_url)
|
||||
goto done;
|
||||
}
|
||||
retString = ToNewCString(spec);
|
||||
|
||||
|
||||
done:
|
||||
NS_IF_RELEASE(url);
|
||||
NS_IF_RELEASE(base);
|
||||
@@ -442,12 +440,12 @@ MimeMultipartRelated_output_child_p(MimeObject *obj, MimeObject* child)
|
||||
{
|
||||
MimeMultipartRelated *relobj = (MimeMultipartRelated *) obj;
|
||||
|
||||
/* rhp - Changed from "if (relobj->head_loaded)" alone to support the
|
||||
/* rhp - Changed from "if (relobj->head_loaded)" alone to support the
|
||||
start parameter
|
||||
*/
|
||||
if (
|
||||
(relobj->head_loaded) ||
|
||||
(MimeStartParamExists(obj, child) && !MimeThisIsStartPart(obj, child))
|
||||
(relobj->head_loaded) ||
|
||||
(MimeStartParamExists(obj, child) && !MimeThisIsStartPart(obj, child))
|
||||
)
|
||||
{
|
||||
/* This is a child part. Just remember the mapping between the URL
|
||||
@@ -502,7 +500,7 @@ MimeMultipartRelated_output_child_p(MimeObject *obj, MimeObject* child)
|
||||
partnum.Append(".2");
|
||||
|
||||
char* part;
|
||||
if (!imappartnum.IsEmpty())
|
||||
if (!imappartnum.IsEmpty())
|
||||
part = mime_set_url_imap_part(obj->options->url, imappartnum.get(), partnum.get());
|
||||
else
|
||||
{
|
||||
@@ -542,20 +540,20 @@ MimeMultipartRelated_output_child_p(MimeObject *obj, MimeObject* child)
|
||||
{
|
||||
char *tloc;
|
||||
char *tmp = MimeHeaders_get(child->headers, HEADER_CONTENT_ID, PR_FALSE, PR_FALSE);
|
||||
if (tmp)
|
||||
if (tmp)
|
||||
{
|
||||
char* tmp2 = tmp;
|
||||
if (*tmp2 == '<')
|
||||
if (*tmp2 == '<')
|
||||
{
|
||||
int length;
|
||||
tmp2++;
|
||||
length = strlen(tmp2);
|
||||
if (length > 0 && tmp2[length - 1] == '>')
|
||||
if (length > 0 && tmp2[length - 1] == '>')
|
||||
{
|
||||
tmp2[length - 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
tloc = PR_smprintf("cid:%s", tmp2);
|
||||
PR_Free(tmp);
|
||||
if (tloc)
|
||||
@@ -666,7 +664,7 @@ MimeMultipartRelated_parse_child_line (MimeObject *obj,
|
||||
nsresult rv;
|
||||
/* Ok, if at this point we still don't have either kind of buffer, try and
|
||||
make a file buffer. */
|
||||
if (!relobj->head_buffer && !relobj->file_buffer)
|
||||
if (!relobj->head_buffer && !relobj->file_buffer)
|
||||
{
|
||||
nsCOMPtr <nsIFile> file;
|
||||
rv = nsMsgCreateTempFile("nsma", getter_AddRefs(file));
|
||||
@@ -676,7 +674,7 @@ MimeMultipartRelated_parse_child_line (MimeObject *obj,
|
||||
rv = NS_NewLocalFileOutputStream(getter_AddRefs(relobj->output_file_stream), relobj->file_buffer, PR_WRONLY | PR_CREATE_FILE, 00600);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
|
||||
PR_ASSERT(relobj->head_buffer || relobj->output_file_stream);
|
||||
|
||||
|
||||
@@ -691,9 +689,9 @@ MimeMultipartRelated_parse_child_line (MimeObject *obj,
|
||||
|
||||
/* If the file isn't open yet, open it, and dump the memory buffer
|
||||
to it. */
|
||||
if (!relobj->output_file_stream)
|
||||
if (!relobj->output_file_stream)
|
||||
{
|
||||
if (!relobj->file_buffer)
|
||||
if (!relobj->file_buffer)
|
||||
{
|
||||
nsCOMPtr <nsIFile> file;
|
||||
rv = nsMsgCreateTempFile("nsma", getter_AddRefs(file));
|
||||
@@ -704,7 +702,7 @@ MimeMultipartRelated_parse_child_line (MimeObject *obj,
|
||||
nsresult rv = NS_NewLocalFileOutputStream(getter_AddRefs(relobj->output_file_stream), relobj->file_buffer, PR_WRONLY | PR_CREATE_FILE, 00600);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (relobj->head_buffer && relobj->head_buffer_fp)
|
||||
if (relobj->head_buffer && relobj->head_buffer_fp)
|
||||
{
|
||||
PRUint32 bytesWritten;
|
||||
status = relobj->output_file_stream->Write(relobj->head_buffer,
|
||||
@@ -722,7 +720,7 @@ MimeMultipartRelated_parse_child_line (MimeObject *obj,
|
||||
/* Dump this line to the file. */
|
||||
PRUint32 bytesWritten;
|
||||
rv = relobj->output_file_stream->Write(line, length, &bytesWritten);
|
||||
if ((PRInt32) bytesWritten < length || NS_FAILED(rv))
|
||||
if ((PRInt32) bytesWritten < length || NS_FAILED(rv))
|
||||
return MIME_UNABLE_TO_OPEN_TMP_FILE;
|
||||
}
|
||||
|
||||
@@ -743,7 +741,7 @@ real_write(MimeMultipartRelated* relobj, const char* buf, PRInt32 size)
|
||||
obj->options->decompose_file_p &&
|
||||
obj->options->decompose_file_output_fn )
|
||||
{
|
||||
return obj->options->decompose_file_output_fn
|
||||
return obj->options->decompose_file_output_fn
|
||||
(buf, size, obj->options->stream_closure);
|
||||
}
|
||||
else
|
||||
@@ -781,7 +779,7 @@ static PRBool accept_related_part(MimeMultipartRelated* relobj, MimeObject* part
|
||||
{
|
||||
if (!relobj || !part_obj)
|
||||
return PR_FALSE;
|
||||
|
||||
|
||||
/* before accepting it as a valid related part, make sure we
|
||||
are able to display it inline as an embedded object. Else just ignore
|
||||
it, that will prevent any bad surprise... */
|
||||
@@ -791,7 +789,7 @@ static PRBool accept_related_part(MimeMultipartRelated* relobj, MimeObject* part
|
||||
|
||||
/* ...but we always accept it if it's referenced by an anchor */
|
||||
return (relobj->curtag && relobj->curtag_length >= 3 &&
|
||||
(relobj->curtag[1] == 'A' || relobj->curtag[1] == 'a') && nsCRT::IsAsciiSpace(relobj->curtag[2]));
|
||||
(relobj->curtag[1] == 'A' || relobj->curtag[1] == 'a') && IS_SPACE(relobj->curtag[2]));
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -800,7 +798,7 @@ flush_tag(MimeMultipartRelated* relobj)
|
||||
int length = relobj->curtag_length;
|
||||
char* buf;
|
||||
int status;
|
||||
|
||||
|
||||
if (relobj->curtag == NULL || length == 0) return 0;
|
||||
|
||||
status = push_tag(relobj, "", 1); /* Push on a trailing NULL. */
|
||||
@@ -821,19 +819,19 @@ flush_tag(MimeMultipartRelated* relobj)
|
||||
quoteDelimiter = *ptr;
|
||||
/* Take up the quote and leading space here as well. */
|
||||
/* Safe because there's a '>' at the end */
|
||||
do {ptr++;} while (nsCRT::IsAsciiSpace(*ptr));
|
||||
do {ptr++;} while (IS_SPACE(*ptr));
|
||||
}
|
||||
}
|
||||
status = real_write(relobj, buf, ptr - buf);
|
||||
if (status < 0) return status;
|
||||
buf = ptr;
|
||||
if (!*buf) break;
|
||||
if (quoteDelimiter)
|
||||
if (quoteDelimiter)
|
||||
{
|
||||
ptr = PL_strnchr(buf, quoteDelimiter, length - (buf - relobj->curtag));
|
||||
} else {
|
||||
for (ptr = buf; *ptr ; ptr++) {
|
||||
if (*ptr == '>' || nsCRT::IsAsciiSpace(*ptr)) break;
|
||||
if (*ptr == '>' || IS_SPACE(*ptr)) break;
|
||||
}
|
||||
PR_ASSERT(*ptr);
|
||||
}
|
||||
@@ -846,13 +844,13 @@ flush_tag(MimeMultipartRelated* relobj)
|
||||
substitute the appropriate mailbox part URL in
|
||||
its place. */
|
||||
ptr2=buf; /* walk from the left end rightward */
|
||||
while((ptr2<ptr) && (!nsCRT::IsAsciiSpace(*ptr2)))
|
||||
while((ptr2<ptr) && (!IS_SPACE(*ptr2)))
|
||||
ptr2++;
|
||||
/* Compare the beginning of the word with "cid:". Yuck. */
|
||||
if (((ptr2 - buf) > 4) &&
|
||||
((buf[0]=='c' || buf[0]=='C') &&
|
||||
(buf[1]=='i' || buf[1]=='I') &&
|
||||
(buf[2]=='d' || buf[2]=='D') &&
|
||||
if (((ptr2 - buf) > 4) &&
|
||||
((buf[0]=='c' || buf[0]=='C') &&
|
||||
(buf[1]=='i' || buf[1]=='I') &&
|
||||
(buf[2]=='d' || buf[2]=='D') &&
|
||||
buf[3]==':'))
|
||||
{
|
||||
// Make sure it's lowercase, otherwise it won't be found in the hash table
|
||||
@@ -861,7 +859,7 @@ flush_tag(MimeMultipartRelated* relobj)
|
||||
/* Null terminate the word so we can... */
|
||||
c = *ptr2;
|
||||
*ptr2 = '\0';
|
||||
|
||||
|
||||
/* Construct a URL out of the word. */
|
||||
absolute = MakeAbsoluteURL(relobj->base_url, buf);
|
||||
|
||||
@@ -875,7 +873,7 @@ flush_tag(MimeMultipartRelated* relobj)
|
||||
part_url = value ? value->m_url : nsnull;
|
||||
PR_FREEIF(absolute);
|
||||
}
|
||||
|
||||
|
||||
/*If we found a mailbox part URL, write that out instead.*/
|
||||
if (part_url && accept_related_part(relobj, value->m_obj))
|
||||
{
|
||||
@@ -887,18 +885,18 @@ flush_tag(MimeMultipartRelated* relobj)
|
||||
if (value->m_obj)
|
||||
value->m_obj->dontShowAsAttachment = PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* Restore the character that we nulled. */
|
||||
*ptr2 = c;
|
||||
}
|
||||
/* rhp - if we get here, we should still check against the hash table! */
|
||||
else
|
||||
else
|
||||
{
|
||||
char holder = *ptr2;
|
||||
char *realout;
|
||||
|
||||
*ptr2 = '\0';
|
||||
|
||||
|
||||
/* Construct a URL out of the word. */
|
||||
absolute = MakeAbsoluteURL(relobj->base_url, buf);
|
||||
|
||||
@@ -929,7 +927,7 @@ flush_tag(MimeMultipartRelated* relobj)
|
||||
|
||||
/* Advance to the beginning of the next word, or to
|
||||
the end of the value string. */
|
||||
while((ptr2<ptr) && (nsCRT::IsAsciiSpace(*ptr2)))
|
||||
while((ptr2<ptr) && (IS_SPACE(*ptr2)))
|
||||
ptr2++;
|
||||
|
||||
/* Write whatever original text remains after
|
||||
@@ -1036,7 +1034,7 @@ MimeMultipartRelated_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
body->dontShowAsAttachment = body->clazz->displayable_inline_p(body->clazz, body->headers);
|
||||
|
||||
#ifdef MIME_DRAFTS
|
||||
if ( obj->options &&
|
||||
if ( obj->options &&
|
||||
obj->options->decompose_file_p &&
|
||||
obj->options->decompose_file_init_fn &&
|
||||
(relobj->file_buffer || relobj->head_buffer))
|
||||
@@ -1052,8 +1050,8 @@ MimeMultipartRelated_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
start its parser going. */
|
||||
status = body->clazz->parse_begin(body);
|
||||
if (status < 0) goto FAIL;
|
||||
|
||||
if (relobj->head_buffer)
|
||||
|
||||
if (relobj->head_buffer)
|
||||
{
|
||||
/* Read it out of memory. */
|
||||
PR_ASSERT(!relobj->file_buffer && !relobj->input_file_stream);
|
||||
@@ -1061,8 +1059,8 @@ MimeMultipartRelated_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
status = body->clazz->parse_buffer(relobj->head_buffer,
|
||||
relobj->head_buffer_fp,
|
||||
body);
|
||||
}
|
||||
else if (relobj->file_buffer)
|
||||
}
|
||||
else if (relobj->file_buffer)
|
||||
{
|
||||
/* Read it off disk. */
|
||||
char *buf;
|
||||
@@ -1071,14 +1069,14 @@ MimeMultipartRelated_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
PR_ASSERT(relobj->head_buffer_size == 0 &&
|
||||
relobj->head_buffer_fp == 0);
|
||||
PR_ASSERT(relobj->file_buffer);
|
||||
if (!relobj->file_buffer)
|
||||
if (!relobj->file_buffer)
|
||||
{
|
||||
status = -1;
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
buf = (char *) PR_MALLOC(buf_size);
|
||||
if (!buf)
|
||||
if (!buf)
|
||||
{
|
||||
status = MIME_OUT_OF_MEMORY;
|
||||
goto FAIL;
|
||||
@@ -1089,23 +1087,23 @@ MimeMultipartRelated_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
relobj->output_file_stream->Close();
|
||||
|
||||
nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(relobj->input_file_stream), relobj->file_buffer);
|
||||
if (NS_FAILED(rv))
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
PR_Free(buf);
|
||||
status = MIME_UNABLE_TO_OPEN_TMP_FILE;
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
while(1)
|
||||
while(1)
|
||||
{
|
||||
PRUint32 bytesRead = 0;
|
||||
rv = relobj->input_file_stream->Read(buf, buf_size - 1, &bytesRead);
|
||||
if (NS_FAILED(rv) || !bytesRead)
|
||||
if (NS_FAILED(rv) || !bytesRead)
|
||||
{
|
||||
status = NS_FAILED(rv) ? -1 : 0;
|
||||
break;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
/* It would be really nice to be able to yield here, and let
|
||||
some user events and other input sources get processed.
|
||||
@@ -1143,7 +1141,7 @@ FAIL:
|
||||
obj->options->output_closure = relobj->real_output_closure;
|
||||
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
#include "msgCore.h"
|
||||
#include "prlog.h"
|
||||
#include "prprf.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsMimeStringResources.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsMsgMessageFlags.h"
|
||||
@@ -57,7 +56,7 @@
|
||||
|
||||
#define MIME_SUPERCLASS mimeContainerClass
|
||||
MimeDefClass(MimeMessage, MimeMessageClass, mimeMessageClass,
|
||||
&MIME_SUPERCLASS);
|
||||
&MIME_SUPERCLASS);
|
||||
|
||||
static int MimeMessage_initialize (MimeObject *);
|
||||
static void MimeMessage_finalize (MimeObject *);
|
||||
@@ -68,8 +67,8 @@ static int MimeMessage_parse_eof (MimeObject *, PRBool);
|
||||
static int MimeMessage_close_headers (MimeObject *obj);
|
||||
static int MimeMessage_write_headers_html (MimeObject *);
|
||||
static char *MimeMessage_partial_message_html(const char *data,
|
||||
void *closure,
|
||||
MimeHeaders *headers);
|
||||
void *closure,
|
||||
MimeHeaders *headers);
|
||||
|
||||
#ifdef MOZ_SECURITY
|
||||
HG56268
|
||||
@@ -121,7 +120,7 @@ MimeMessage_finalize (MimeObject *object)
|
||||
{
|
||||
MimeMessage *msg = (MimeMessage *)object;
|
||||
if (msg->hdrs)
|
||||
MimeHeaders_free(msg->hdrs);
|
||||
MimeHeaders_free(msg->hdrs);
|
||||
msg->hdrs = 0;
|
||||
((MimeObjectClass*)&MIME_SUPERCLASS)->finalize(object);
|
||||
}
|
||||
@@ -140,7 +139,7 @@ MimeMessage_parse_begin (MimeObject *obj)
|
||||
}
|
||||
|
||||
/* Messages have separators before the headers, except for the outermost
|
||||
message. */
|
||||
message. */
|
||||
return MimeObject_write_separator(obj);
|
||||
}
|
||||
|
||||
@@ -183,93 +182,93 @@ MimeMessage_parse_line (const char *aLine, PRInt32 aLength, MimeObject *obj)
|
||||
}
|
||||
|
||||
/* If we already have a child object, then we're done parsing headers,
|
||||
and all subsequent lines get passed to the inferior object without
|
||||
further processing by us. (Our parent will stop feeding us lines
|
||||
when this MimeMessage part is out of data.)
|
||||
and all subsequent lines get passed to the inferior object without
|
||||
further processing by us. (Our parent will stop feeding us lines
|
||||
when this MimeMessage part is out of data.)
|
||||
*/
|
||||
if (msg->container.nchildren)
|
||||
{
|
||||
MimeObject *kid = msg->container.children[0];
|
||||
PRBool nl;
|
||||
PR_ASSERT(kid);
|
||||
if (!kid) return -1;
|
||||
{
|
||||
MimeObject *kid = msg->container.children[0];
|
||||
PRBool nl;
|
||||
PR_ASSERT(kid);
|
||||
if (!kid) return -1;
|
||||
|
||||
msg->bodyLength += length;
|
||||
|
||||
/* Don't allow MimeMessage objects to not end in a newline, since it
|
||||
would be inappropriate for any following part to appear on the same
|
||||
line as the last line of the message.
|
||||
/* Don't allow MimeMessage objects to not end in a newline, since it
|
||||
would be inappropriate for any following part to appear on the same
|
||||
line as the last line of the message.
|
||||
|
||||
#### This assumes that the only time the `parse_line' method is
|
||||
called with a line that doesn't end in a newline is when that line
|
||||
is the last line.
|
||||
*/
|
||||
nl = (length > 0 && (line[length-1] == '\r' || line[length-1] == '\n'));
|
||||
#### This assumes that the only time the `parse_line' method is
|
||||
called with a line that doesn't end in a newline is when that line
|
||||
is the last line.
|
||||
*/
|
||||
nl = (length > 0 && (line[length-1] == '\r' || line[length-1] == '\n'));
|
||||
|
||||
#ifdef MIME_DRAFTS
|
||||
if ( !mime_typep (kid, (MimeObjectClass*) &mimeMessageClass) &&
|
||||
obj->options &&
|
||||
obj->options->decompose_file_p &&
|
||||
! obj->options->is_multipart_msg &&
|
||||
obj->options->decompose_file_output_fn )
|
||||
{
|
||||
if (!obj->options->decrypt_p) {
|
||||
if ( !mime_typep (kid, (MimeObjectClass*) &mimeMessageClass) &&
|
||||
obj->options &&
|
||||
obj->options->decompose_file_p &&
|
||||
! obj->options->is_multipart_msg &&
|
||||
obj->options->decompose_file_output_fn )
|
||||
{
|
||||
if (!obj->options->decrypt_p) {
|
||||
//if we are processing a flowed plain text line, we need to remove any stuffed space
|
||||
if (length > 0 && ' ' == *line && mime_typep(kid, (MimeObjectClass *)&mimeInlineTextPlainFlowedClass))
|
||||
{
|
||||
line ++;
|
||||
length --;
|
||||
}
|
||||
status = obj->options->decompose_file_output_fn (line,
|
||||
length,
|
||||
obj->options->stream_closure);
|
||||
if (status < 0) return status;
|
||||
if (!nl) {
|
||||
status = obj->options->decompose_file_output_fn (MSG_LINEBREAK,
|
||||
MSG_LINEBREAK_LEN,
|
||||
obj->options->stream_closure);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
}
|
||||
status = obj->options->decompose_file_output_fn (line,
|
||||
length,
|
||||
obj->options->stream_closure);
|
||||
if (status < 0) return status;
|
||||
if (!nl) {
|
||||
status = obj->options->decompose_file_output_fn (MSG_LINEBREAK,
|
||||
MSG_LINEBREAK_LEN,
|
||||
obj->options->stream_closure);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
}
|
||||
#endif /* MIME_DRAFTS */
|
||||
|
||||
|
||||
if (nl)
|
||||
return kid->clazz->parse_buffer (line, length, kid);
|
||||
else
|
||||
{
|
||||
/* Hack a newline onto the end. */
|
||||
char *s = (char *)PR_MALLOC(length + MSG_LINEBREAK_LEN + 1);
|
||||
if (!s) return MIME_OUT_OF_MEMORY;
|
||||
memcpy(s, line, length);
|
||||
PL_strcpy(s + length, MSG_LINEBREAK);
|
||||
status = kid->clazz->parse_buffer (s, length + MSG_LINEBREAK_LEN, kid);
|
||||
PR_Free(s);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
if (nl)
|
||||
return kid->clazz->parse_buffer (line, length, kid);
|
||||
else
|
||||
{
|
||||
/* Hack a newline onto the end. */
|
||||
char *s = (char *)PR_MALLOC(length + MSG_LINEBREAK_LEN + 1);
|
||||
if (!s) return MIME_OUT_OF_MEMORY;
|
||||
memcpy(s, line, length);
|
||||
PL_strcpy(s + length, MSG_LINEBREAK);
|
||||
status = kid->clazz->parse_buffer (s, length + MSG_LINEBREAK_LEN, kid);
|
||||
PR_Free(s);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
/* Otherwise we don't yet have a child object, which means we're not
|
||||
done parsing our headers yet.
|
||||
done parsing our headers yet.
|
||||
*/
|
||||
if (!msg->hdrs)
|
||||
{
|
||||
msg->hdrs = MimeHeaders_new();
|
||||
if (!msg->hdrs) return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
{
|
||||
msg->hdrs = MimeHeaders_new();
|
||||
if (!msg->hdrs) return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
#ifdef MIME_DRAFTS
|
||||
if ( obj->options &&
|
||||
obj->options->decompose_file_p &&
|
||||
! obj->options->is_multipart_msg &&
|
||||
obj->options->done_parsing_outer_headers &&
|
||||
obj->options->decompose_file_output_fn )
|
||||
obj->options->decompose_file_p &&
|
||||
! obj->options->is_multipart_msg &&
|
||||
obj->options->done_parsing_outer_headers &&
|
||||
obj->options->decompose_file_output_fn )
|
||||
{
|
||||
status = obj->options->decompose_file_output_fn( line, length,
|
||||
obj->options->stream_closure );
|
||||
if (status < 0)
|
||||
status = obj->options->decompose_file_output_fn( line, length,
|
||||
obj->options->stream_closure );
|
||||
if (status < 0)
|
||||
return status;
|
||||
}
|
||||
#endif /* MIME_DRAFTS */
|
||||
@@ -278,13 +277,13 @@ MimeMessage_parse_line (const char *aLine, PRInt32 aLength, MimeObject *obj)
|
||||
if (status < 0) return status;
|
||||
|
||||
/* If this line is blank, we're now done parsing headers, and should
|
||||
examine our content-type to create our "body" part.
|
||||
examine our content-type to create our "body" part.
|
||||
*/
|
||||
if (*line == '\r' || *line == '\n')
|
||||
{
|
||||
status = MimeMessage_close_headers(obj);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
{
|
||||
status = MimeMessage_close_headers(obj);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -294,111 +293,111 @@ MimeMessage_close_headers (MimeObject *obj)
|
||||
{
|
||||
MimeMessage *msg = (MimeMessage *) obj;
|
||||
int status = 0;
|
||||
char *ct = 0; /* Content-Type header */
|
||||
char *ct = 0; /* Content-Type header */
|
||||
MimeObject *body;
|
||||
|
||||
if (msg->hdrs)
|
||||
{
|
||||
PRBool outer_p = !obj->headers; /* is this the outermost message? */
|
||||
{
|
||||
PRBool outer_p = !obj->headers; /* is this the outermost message? */
|
||||
|
||||
|
||||
#ifdef MIME_DRAFTS
|
||||
if (outer_p &&
|
||||
obj->options &&
|
||||
if (outer_p &&
|
||||
obj->options &&
|
||||
(obj->options->decompose_file_p || obj->options->caller_need_root_headers) &&
|
||||
obj->options->decompose_headers_info_fn)
|
||||
{
|
||||
obj->options->decompose_headers_info_fn)
|
||||
{
|
||||
#ifdef ENABLE_SMIME
|
||||
if (obj->options->decrypt_p && !mime_crypto_object_p (msg->hdrs, PR_FALSE))
|
||||
obj->options->decrypt_p = PR_FALSE;
|
||||
#endif /* ENABLE_SMIME */
|
||||
if (!obj->options->caller_need_root_headers || (obj == obj->options->state->root))
|
||||
status = obj->options->decompose_headers_info_fn (
|
||||
obj->options->stream_closure,
|
||||
msg->hdrs );
|
||||
}
|
||||
status = obj->options->decompose_headers_info_fn (
|
||||
obj->options->stream_closure,
|
||||
msg->hdrs );
|
||||
}
|
||||
#endif /* MIME_DRAFTS */
|
||||
|
||||
|
||||
/* If this is the outermost message, we need to run the
|
||||
`generate_header' callback. This happens here instead of
|
||||
in `parse_begin', because it's only now that we've parsed
|
||||
our headers. However, since this is the outermost message,
|
||||
we have yet to write any HTML, so that's fine.
|
||||
*/
|
||||
if (outer_p &&
|
||||
obj->output_p &&
|
||||
obj->options &&
|
||||
obj->options->write_html_p &&
|
||||
obj->options->generate_header_html_fn)
|
||||
{
|
||||
int lstatus = 0;
|
||||
char *html = 0;
|
||||
/* If this is the outermost message, we need to run the
|
||||
`generate_header' callback. This happens here instead of
|
||||
in `parse_begin', because it's only now that we've parsed
|
||||
our headers. However, since this is the outermost message,
|
||||
we have yet to write any HTML, so that's fine.
|
||||
*/
|
||||
if (outer_p &&
|
||||
obj->output_p &&
|
||||
obj->options &&
|
||||
obj->options->write_html_p &&
|
||||
obj->options->generate_header_html_fn)
|
||||
{
|
||||
int lstatus = 0;
|
||||
char *html = 0;
|
||||
|
||||
/* The generate_header_html_fn might return HTML, so it's important
|
||||
that the output stream be set up with the proper type before we
|
||||
make the MimeObject_write() call below. */
|
||||
if (!obj->options->state->first_data_written_p)
|
||||
{
|
||||
lstatus = MimeObject_output_init (obj, TEXT_HTML);
|
||||
if (lstatus < 0) return lstatus;
|
||||
PR_ASSERT(obj->options->state->first_data_written_p);
|
||||
}
|
||||
/* The generate_header_html_fn might return HTML, so it's important
|
||||
that the output stream be set up with the proper type before we
|
||||
make the MimeObject_write() call below. */
|
||||
if (!obj->options->state->first_data_written_p)
|
||||
{
|
||||
lstatus = MimeObject_output_init (obj, TEXT_HTML);
|
||||
if (lstatus < 0) return lstatus;
|
||||
PR_ASSERT(obj->options->state->first_data_written_p);
|
||||
}
|
||||
|
||||
html = obj->options->generate_header_html_fn(NULL,
|
||||
obj->options->html_closure,
|
||||
msg->hdrs);
|
||||
if (html)
|
||||
{
|
||||
lstatus = MimeObject_write(obj, html, strlen(html), PR_FALSE);
|
||||
PR_Free(html);
|
||||
if (lstatus < 0) return lstatus;
|
||||
}
|
||||
}
|
||||
html = obj->options->generate_header_html_fn(NULL,
|
||||
obj->options->html_closure,
|
||||
msg->hdrs);
|
||||
if (html)
|
||||
{
|
||||
lstatus = MimeObject_write(obj, html, strlen(html), PR_FALSE);
|
||||
PR_Free(html);
|
||||
if (lstatus < 0) return lstatus;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Find the content-type of the body of this message.
|
||||
*/
|
||||
{
|
||||
PRBool ok = PR_TRUE;
|
||||
char *mv = MimeHeaders_get (msg->hdrs, HEADER_MIME_VERSION,
|
||||
PR_TRUE, PR_FALSE);
|
||||
/* Find the content-type of the body of this message.
|
||||
*/
|
||||
{
|
||||
PRBool ok = PR_TRUE;
|
||||
char *mv = MimeHeaders_get (msg->hdrs, HEADER_MIME_VERSION,
|
||||
PR_TRUE, PR_FALSE);
|
||||
|
||||
#ifdef REQUIRE_MIME_VERSION_HEADER
|
||||
/* If this is the outermost message, it must have a MIME-Version
|
||||
header with the value 1.0 for us to believe what might be in
|
||||
the Content-Type header. If the MIME-Version header is not
|
||||
present, we must treat this message as untyped.
|
||||
*/
|
||||
ok = (mv && !nsCRT::strcmp(mv, "1.0"));
|
||||
/* If this is the outermost message, it must have a MIME-Version
|
||||
header with the value 1.0 for us to believe what might be in
|
||||
the Content-Type header. If the MIME-Version header is not
|
||||
present, we must treat this message as untyped.
|
||||
*/
|
||||
ok = (mv && !strcmp(mv, "1.0"));
|
||||
#else
|
||||
/* #### actually, we didn't check this in Mozilla 2.0, and checking
|
||||
it now could cause some compatibility nonsense, so for now, let's
|
||||
just believe any Content-Type header we see.
|
||||
*/
|
||||
ok = PR_TRUE;
|
||||
/* #### actually, we didn't check this in Mozilla 2.0, and checking
|
||||
it now could cause some compatibility nonsense, so for now, let's
|
||||
just believe any Content-Type header we see.
|
||||
*/
|
||||
ok = PR_TRUE;
|
||||
#endif
|
||||
|
||||
if (ok)
|
||||
{
|
||||
ct = MimeHeaders_get (msg->hdrs, HEADER_CONTENT_TYPE, PR_TRUE, PR_FALSE);
|
||||
if (ok)
|
||||
{
|
||||
ct = MimeHeaders_get (msg->hdrs, HEADER_CONTENT_TYPE, PR_TRUE, PR_FALSE);
|
||||
|
||||
/* If there is no Content-Type header, but there is a MIME-Version
|
||||
header, then assume that this *is* in fact a MIME message.
|
||||
(I've seen messages with
|
||||
/* If there is no Content-Type header, but there is a MIME-Version
|
||||
header, then assume that this *is* in fact a MIME message.
|
||||
(I've seen messages with
|
||||
|
||||
MIME-Version: 1.0
|
||||
Content-Transfer-Encoding: quoted-printable
|
||||
MIME-Version: 1.0
|
||||
Content-Transfer-Encoding: quoted-printable
|
||||
|
||||
and no Content-Type, and we should treat those as being of type
|
||||
MimeInlineTextPlain rather than MimeUntypedText.)
|
||||
*/
|
||||
if (mv && !ct)
|
||||
ct = nsCRT::strdup(TEXT_PLAIN);
|
||||
}
|
||||
and no Content-Type, and we should treat those as being of type
|
||||
MimeInlineTextPlain rather than MimeUntypedText.)
|
||||
*/
|
||||
if (mv && !ct)
|
||||
ct = strdup(TEXT_PLAIN);
|
||||
}
|
||||
|
||||
PR_FREEIF(mv); /* done with this now. */
|
||||
}
|
||||
PR_FREEIF(mv); /* done with this now. */
|
||||
}
|
||||
|
||||
/* If this message has a body which is encrypted and we're going to
|
||||
decrypt it (whithout converting it to HTML, since decrypt_p and
|
||||
@@ -420,49 +419,49 @@ MimeMessage_close_headers (MimeObject *obj)
|
||||
obj->options->decrypt_p = PR_FALSE;
|
||||
}
|
||||
|
||||
/* Emit the HTML for this message's headers. Do this before
|
||||
creating the object representing the body.
|
||||
*/
|
||||
if (obj->output_p &&
|
||||
obj->options &&
|
||||
obj->options->write_html_p)
|
||||
{
|
||||
/* If citation headers are on, and this is not the outermost message,
|
||||
turn them off. */
|
||||
if (obj->options->headers == MimeHeadersCitation && !outer_p)
|
||||
obj->options->headers = MimeHeadersSome;
|
||||
/* Emit the HTML for this message's headers. Do this before
|
||||
creating the object representing the body.
|
||||
*/
|
||||
if (obj->output_p &&
|
||||
obj->options &&
|
||||
obj->options->write_html_p)
|
||||
{
|
||||
/* If citation headers are on, and this is not the outermost message,
|
||||
turn them off. */
|
||||
if (obj->options->headers == MimeHeadersCitation && !outer_p)
|
||||
obj->options->headers = MimeHeadersSome;
|
||||
|
||||
/* Emit a normal header block. */
|
||||
status = MimeMessage_write_headers_html(obj);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
else if (obj->output_p)
|
||||
{
|
||||
/* Dump the headers, raw. */
|
||||
status = MimeObject_write(obj, "", 0, PR_FALSE); /* initialize */
|
||||
if (status < 0) return status;
|
||||
status = MimeHeaders_write_raw_headers(msg->hdrs, obj->options,
|
||||
obj->options->decrypt_p);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
/* Emit a normal header block. */
|
||||
status = MimeMessage_write_headers_html(obj);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
else if (obj->output_p)
|
||||
{
|
||||
/* Dump the headers, raw. */
|
||||
status = MimeObject_write(obj, "", 0, PR_FALSE); /* initialize */
|
||||
if (status < 0) return status;
|
||||
status = MimeHeaders_write_raw_headers(msg->hdrs, obj->options,
|
||||
obj->options->decrypt_p);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
|
||||
#ifdef XP_UNIX
|
||||
if (outer_p && obj->output_p)
|
||||
/* Kludge from mimehdrs.c */
|
||||
MimeHeaders_do_unix_display_hook_hack(msg->hdrs);
|
||||
if (outer_p && obj->output_p)
|
||||
/* Kludge from mimehdrs.c */
|
||||
MimeHeaders_do_unix_display_hook_hack(msg->hdrs);
|
||||
#endif /* XP_UNIX */
|
||||
}
|
||||
}
|
||||
|
||||
/* Never put out a separator after a message header block. */
|
||||
if (obj->options && obj->options->state)
|
||||
obj->options->state->separator_suppressed_p = PR_TRUE;
|
||||
obj->options->state->separator_suppressed_p = PR_TRUE;
|
||||
|
||||
#ifdef MIME_DRAFTS
|
||||
if ( !obj->headers && /* outer most message header */
|
||||
obj->options &&
|
||||
obj->options->decompose_file_p &&
|
||||
ct )
|
||||
obj->options->is_multipart_msg = PL_strcasestr(ct, "multipart/") != NULL;
|
||||
obj->options &&
|
||||
obj->options->decompose_file_p &&
|
||||
ct )
|
||||
obj->options->is_multipart_msg = PL_strcasestr(ct, "multipart/") != NULL;
|
||||
#endif /* MIME_DRAFTS */
|
||||
|
||||
|
||||
@@ -472,11 +471,11 @@ MimeMessage_close_headers (MimeObject *obj)
|
||||
if (!body) return MIME_OUT_OF_MEMORY;
|
||||
status = ((MimeContainerClass *) obj->clazz)->add_child (obj, body);
|
||||
if (status < 0)
|
||||
{
|
||||
mime_free(body);
|
||||
return status;
|
||||
}
|
||||
|
||||
{
|
||||
mime_free(body);
|
||||
return status;
|
||||
}
|
||||
|
||||
// Only do this if this is a Text Object!
|
||||
if ( mime_typep(body, (MimeObjectClass *) &mimeInlineTextClass) )
|
||||
{
|
||||
@@ -484,15 +483,15 @@ MimeMessage_close_headers (MimeObject *obj)
|
||||
}
|
||||
|
||||
/* Now that we've added this new object to our list of children,
|
||||
start its parser going. */
|
||||
start its parser going. */
|
||||
status = body->clazz->parse_begin(body);
|
||||
if (status < 0) return status;
|
||||
|
||||
// Now notify the emitter if this is the outer most message, unless
|
||||
// it is a part that is not the head of the message. If it's a part,
|
||||
// it is a part that is not the head of the message. If it's a part,
|
||||
// we need to figure out the content type/charset of the part
|
||||
//
|
||||
PRBool outer_p = !obj->headers; /* is this the outermost message? */
|
||||
PRBool outer_p = !obj->headers; /* is this the outermost message? */
|
||||
|
||||
if ( outer_p &&
|
||||
(!obj->options->part_to_load || obj->options->format_out == nsMimeOutput::nsMimeMessageBodyDisplay))
|
||||
@@ -506,7 +505,7 @@ MimeMessage_close_headers (MimeObject *obj)
|
||||
}
|
||||
|
||||
char *msgID = MimeHeaders_get (msg->hdrs, HEADER_MESSAGE_ID,
|
||||
PR_FALSE, PR_FALSE);
|
||||
PR_FALSE, PR_FALSE);
|
||||
|
||||
const char *outCharset = NULL;
|
||||
if (!obj->options->force_user_charset) /* Only convert if the user prefs is false */
|
||||
@@ -515,22 +514,22 @@ MimeMessage_close_headers (MimeObject *obj)
|
||||
mimeEmitterStartBody(obj->options, (obj->options->headers == MimeHeadersNone), msgID, outCharset);
|
||||
PR_FREEIF(msgID);
|
||||
|
||||
// setting up truncated message html fotter function
|
||||
char *xmoz = MimeHeaders_get(msg->hdrs, HEADER_X_MOZILLA_STATUS, PR_FALSE,
|
||||
PR_FALSE);
|
||||
if (xmoz)
|
||||
{
|
||||
PRUint32 flags = 0;
|
||||
char dummy = 0;
|
||||
if (sscanf(xmoz, " %lx %c", &flags, &dummy) == 1 &&
|
||||
flags & MSG_FLAG_PARTIAL)
|
||||
{
|
||||
obj->options->html_closure = obj;
|
||||
obj->options->generate_footer_html_fn =
|
||||
MimeMessage_partial_message_html;
|
||||
}
|
||||
PR_FREEIF(xmoz);
|
||||
}
|
||||
// setting up truncated message html fotter function
|
||||
char *xmoz = MimeHeaders_get(msg->hdrs, HEADER_X_MOZILLA_STATUS, PR_FALSE,
|
||||
PR_FALSE);
|
||||
if (xmoz)
|
||||
{
|
||||
PRUint32 flags = 0;
|
||||
char dummy = 0;
|
||||
if (sscanf(xmoz, " %lx %c", &flags, &dummy) == 1 &&
|
||||
flags & MSG_FLAG_PARTIAL)
|
||||
{
|
||||
obj->options->html_closure = obj;
|
||||
obj->options->generate_footer_html_fn =
|
||||
MimeMessage_partial_message_html;
|
||||
}
|
||||
PR_FREEIF(xmoz);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -538,19 +537,19 @@ MimeMessage_close_headers (MimeObject *obj)
|
||||
|
||||
|
||||
|
||||
static int
|
||||
static int
|
||||
MimeMessage_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
{
|
||||
int status;
|
||||
PRBool outer_p;
|
||||
MimeMessage *msg = (MimeMessage *)obj;
|
||||
if (obj->closed_p) return 0;
|
||||
|
||||
|
||||
/* Run parent method first, to flush out any buffered data. */
|
||||
status = ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_eof(obj, abort_p);
|
||||
if (status < 0) return status;
|
||||
|
||||
outer_p = !obj->headers; /* is this the outermost message? */
|
||||
outer_p = !obj->headers; /* is this the outermost message? */
|
||||
|
||||
// Hack for messages with truncated headers (bug 244722)
|
||||
// If there is no empty line in a message, the parser can't figure out where
|
||||
@@ -568,50 +567,50 @@ MimeMessage_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
// body of the message (i.e. not Header ONLY)
|
||||
if (outer_p && obj->options && obj->options->write_html_p)
|
||||
{
|
||||
if (obj->options->generate_footer_html_fn)
|
||||
{
|
||||
mime_stream_data *msd =
|
||||
(mime_stream_data *) obj->options->stream_closure;
|
||||
if (msd)
|
||||
{
|
||||
char *html = obj->options->generate_footer_html_fn
|
||||
(msd->orig_url_name, obj->options->html_closure, msg->hdrs);
|
||||
if (html)
|
||||
{
|
||||
int lstatus = MimeObject_write(obj, html,
|
||||
strlen(html),
|
||||
PR_FALSE);
|
||||
PR_Free(html);
|
||||
if (lstatus < 0) return lstatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((!obj->options->part_to_load || obj->options->format_out == nsMimeOutput::nsMimeMessageBodyDisplay) &&
|
||||
obj->options->headers != MimeHeadersOnly)
|
||||
mimeEmitterEndBody(obj->options);
|
||||
if (obj->options->generate_footer_html_fn)
|
||||
{
|
||||
mime_stream_data *msd =
|
||||
(mime_stream_data *) obj->options->stream_closure;
|
||||
if (msd)
|
||||
{
|
||||
char *html = obj->options->generate_footer_html_fn
|
||||
(msd->orig_url_name, obj->options->html_closure, msg->hdrs);
|
||||
if (html)
|
||||
{
|
||||
int lstatus = MimeObject_write(obj, html,
|
||||
strlen(html),
|
||||
PR_FALSE);
|
||||
PR_Free(html);
|
||||
if (lstatus < 0) return lstatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((!obj->options->part_to_load || obj->options->format_out == nsMimeOutput::nsMimeMessageBodyDisplay) &&
|
||||
obj->options->headers != MimeHeadersOnly)
|
||||
mimeEmitterEndBody(obj->options);
|
||||
}
|
||||
|
||||
#ifdef MIME_DRAFTS
|
||||
if ( obj->options &&
|
||||
obj->options->decompose_file_p &&
|
||||
obj->options->done_parsing_outer_headers &&
|
||||
! obj->options->is_multipart_msg &&
|
||||
! mime_typep(obj, (MimeObjectClass*) &mimeEncryptedClass) &&
|
||||
obj->options->decompose_file_close_fn ) {
|
||||
status = obj->options->decompose_file_close_fn (
|
||||
obj->options->stream_closure );
|
||||
obj->options->decompose_file_p &&
|
||||
obj->options->done_parsing_outer_headers &&
|
||||
! obj->options->is_multipart_msg &&
|
||||
! mime_typep(obj, (MimeObjectClass*) &mimeEncryptedClass) &&
|
||||
obj->options->decompose_file_close_fn ) {
|
||||
status = obj->options->decompose_file_close_fn (
|
||||
obj->options->stream_closure );
|
||||
|
||||
if ( status < 0 ) return status;
|
||||
if ( status < 0 ) return status;
|
||||
}
|
||||
#endif /* MIME_DRAFTS */
|
||||
|
||||
|
||||
/* Put out a separator after every message/rfc822 object. */
|
||||
if (!abort_p && !outer_p)
|
||||
{
|
||||
status = MimeObject_write_separator(obj);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
{
|
||||
status = MimeObject_write_separator(obj);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -630,18 +629,18 @@ MimeMessage_add_child (MimeObject *parent, MimeObject *child)
|
||||
|
||||
#ifdef MIME_DRAFTS
|
||||
if ( parent->options &&
|
||||
parent->options->decompose_file_p &&
|
||||
! parent->options->is_multipart_msg &&
|
||||
! mime_typep(child, (MimeObjectClass*) &mimeEncryptedClass) &&
|
||||
parent->options->decompose_file_init_fn ) {
|
||||
int status = 0;
|
||||
status = parent->options->decompose_file_init_fn (
|
||||
parent->options->stream_closure,
|
||||
((MimeMessage*)parent)->hdrs );
|
||||
if ( status < 0 ) return status;
|
||||
parent->options->decompose_file_p &&
|
||||
! parent->options->is_multipart_msg &&
|
||||
! mime_typep(child, (MimeObjectClass*) &mimeEncryptedClass) &&
|
||||
parent->options->decompose_file_init_fn ) {
|
||||
int status = 0;
|
||||
status = parent->options->decompose_file_init_fn (
|
||||
parent->options->stream_closure,
|
||||
((MimeMessage*)parent)->hdrs );
|
||||
if ( status < 0 ) return status;
|
||||
}
|
||||
#endif /* MIME_DRAFTS */
|
||||
|
||||
|
||||
return ((MimeContainerClass*)&MIME_SUPERCLASS)->add_child (parent, child);
|
||||
}
|
||||
|
||||
@@ -650,7 +649,7 @@ char *
|
||||
DetermineMailCharset(MimeMessage *msg)
|
||||
{
|
||||
char *retCharset = nsnull;
|
||||
|
||||
|
||||
if ( (msg) && (msg->hdrs) )
|
||||
{
|
||||
char *ct = MimeHeaders_get (msg->hdrs, HEADER_CONTENT_TYPE,
|
||||
@@ -660,7 +659,7 @@ DetermineMailCharset(MimeMessage *msg)
|
||||
retCharset = MimeHeaders_get_parameter (ct, "charset", NULL, NULL);
|
||||
PR_Free(ct);
|
||||
}
|
||||
|
||||
|
||||
if (!retCharset)
|
||||
{
|
||||
// If we didn't find "Content-Type: ...; charset=XX" then look
|
||||
@@ -668,11 +667,11 @@ DetermineMailCharset(MimeMessage *msg)
|
||||
// in MimeSunAttachmentClass, but it's harder there than here.)
|
||||
retCharset = MimeHeaders_get (msg->hdrs, HEADER_X_SUN_CHARSET,
|
||||
PR_FALSE, PR_FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!retCharset)
|
||||
return nsCRT::strdup("ISO-8859-1");
|
||||
return strdup("ISO-8859-1");
|
||||
else
|
||||
return retCharset;
|
||||
}
|
||||
@@ -685,10 +684,10 @@ MimeMessage_write_headers_html (MimeObject *obj)
|
||||
|
||||
#ifdef MOZ_SECURITY
|
||||
HG33391
|
||||
#endif /* MOZ_SECURITY */
|
||||
#endif /* MOZ_SECURITY */
|
||||
|
||||
if (!obj->options || !obj->options->output_fn)
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
PR_ASSERT(obj->output_p && obj->options->write_html_p);
|
||||
|
||||
@@ -701,7 +700,7 @@ MimeMessage_write_headers_html (MimeObject *obj)
|
||||
// operation ONLY WHEN THE CHARSET OF THE ORIGINAL MESSAGE IS
|
||||
// NOT US-ASCII ("ISO-8859-1")
|
||||
//
|
||||
// This is only to notify the emitter of the charset of the
|
||||
// This is only to notify the emitter of the charset of the
|
||||
// original message
|
||||
char *mailCharset = DetermineMailCharset(msg);
|
||||
|
||||
@@ -713,19 +712,19 @@ MimeMessage_write_headers_html (MimeObject *obj)
|
||||
}
|
||||
|
||||
if (!obj->options->state->first_data_written_p)
|
||||
{
|
||||
status = MimeObject_output_init (obj, TEXT_HTML);
|
||||
if (status < 0)
|
||||
{
|
||||
status = MimeObject_output_init (obj, TEXT_HTML);
|
||||
if (status < 0)
|
||||
{
|
||||
mimeEmitterEndHeader(obj->options);
|
||||
return status;
|
||||
}
|
||||
PR_ASSERT(obj->options->state->first_data_written_p);
|
||||
}
|
||||
PR_ASSERT(obj->options->state->first_data_written_p);
|
||||
}
|
||||
|
||||
// Start the header parsing by the emitter
|
||||
char *msgID = MimeHeaders_get (msg->hdrs, HEADER_MESSAGE_ID,
|
||||
PR_FALSE, PR_FALSE);
|
||||
PR_FALSE, PR_FALSE);
|
||||
PRBool outer_p = !obj->headers; /* is this the outermost message? */
|
||||
if (!outer_p && obj->options->format_out == nsMimeOutput::nsMimeMessageBodyDisplay &&
|
||||
obj->options->part_to_load)
|
||||
@@ -744,8 +743,8 @@ MimeMessage_write_headers_html (MimeObject *obj)
|
||||
// reply and forward operations.
|
||||
//
|
||||
char *mailCharset = DetermineMailCharset(msg);
|
||||
mimeEmitterStartHeader(obj->options,
|
||||
outer_p,
|
||||
mimeEmitterStartHeader(obj->options,
|
||||
outer_p,
|
||||
(obj->options->headers == MimeHeadersOnly),
|
||||
msgID,
|
||||
mailCharset);
|
||||
@@ -753,11 +752,11 @@ MimeMessage_write_headers_html (MimeObject *obj)
|
||||
PR_FREEIF(mailCharset);
|
||||
|
||||
#ifdef MOZ_SECURITY
|
||||
HG00919
|
||||
HG00919
|
||||
#endif /* MOZ_SECURITY */
|
||||
|
||||
status = MimeHeaders_write_all_headers (msg->hdrs, obj->options, PR_FALSE);
|
||||
if (status < 0)
|
||||
if (status < 0)
|
||||
{
|
||||
mimeEmitterEndHeader(obj->options);
|
||||
return status;
|
||||
@@ -767,7 +766,7 @@ MimeMessage_write_headers_html (MimeObject *obj)
|
||||
{
|
||||
#ifdef MOZ_SECURITY
|
||||
HG11995
|
||||
#endif /* MOZ_SECURITY */
|
||||
#endif /* MOZ_SECURITY */
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -776,7 +775,7 @@ MimeMessage_write_headers_html (MimeObject *obj)
|
||||
(Otherwise, it will be run when the xlation-stamp is finally
|
||||
closed off, in MimeXlateed_emit_buffered_child() or
|
||||
MimeMultipartSigned_emit_child().)
|
||||
*/
|
||||
*/
|
||||
if (obj->options &&
|
||||
obj->options->state &&
|
||||
obj->options->generate_post_header_html_fn &&
|
||||
@@ -792,13 +791,13 @@ MimeMessage_write_headers_html (MimeObject *obj)
|
||||
{
|
||||
status = MimeObject_write(obj, html, strlen(html), PR_FALSE);
|
||||
PR_Free(html);
|
||||
if (status < 0)
|
||||
if (status < 0)
|
||||
{
|
||||
mimeEmitterEndHeader(obj->options);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mimeEmitterEndHeader(obj->options);
|
||||
@@ -820,14 +819,14 @@ MimeMessage_write_headers_html (MimeObject *obj)
|
||||
|
||||
static char *
|
||||
MimeMessage_partial_message_html(const char *data, void *closure,
|
||||
MimeHeaders *headers)
|
||||
MimeHeaders *headers)
|
||||
{
|
||||
MimeMessage *msg = (MimeMessage *)closure;
|
||||
nsCAutoString orig_url(data);
|
||||
char *partialMsgHtml = nsnull;
|
||||
char *uidl = MimeHeaders_get(headers, HEADER_X_UIDL, PR_FALSE, PR_FALSE);
|
||||
char *msgId = MimeHeaders_get(headers, HEADER_MESSAGE_ID, PR_FALSE,
|
||||
PR_FALSE);
|
||||
PR_FALSE);
|
||||
char *msgIdPtr = PL_strstr(msgId, "<");
|
||||
int msgBase;
|
||||
|
||||
@@ -860,7 +859,7 @@ MimeMessage_partial_message_html(const char *data, void *closure,
|
||||
PR_Free(fmt2);
|
||||
PR_Free(fmt3);
|
||||
|
||||
return partialMsgHtml;
|
||||
return partialMsgHtml;
|
||||
}
|
||||
|
||||
#if defined(DEBUG) && defined(XP_UNIX)
|
||||
@@ -871,33 +870,33 @@ MimeMessage_debug_print (MimeObject *obj, PRFileDesc *stream, PRInt32 depth)
|
||||
char *addr = mime_part_address(obj);
|
||||
int i;
|
||||
for (i=0; i < depth; i++)
|
||||
PR_Write(stream, " ", 2);
|
||||
PR_Write(stream, " ", 2);
|
||||
/*
|
||||
fprintf(stream, "<%s %s%s 0x%08X>\n",
|
||||
obj->clazz->class_name,
|
||||
addr ? addr : "???",
|
||||
(msg->container.nchildren == 0 ? " (no body)" : ""),
|
||||
(PRUint32) msg);
|
||||
obj->clazz->class_name,
|
||||
addr ? addr : "???",
|
||||
(msg->container.nchildren == 0 ? " (no body)" : ""),
|
||||
(PRUint32) msg);
|
||||
*/
|
||||
PR_FREEIF(addr);
|
||||
|
||||
#if 0
|
||||
if (msg->hdrs)
|
||||
{
|
||||
char *s;
|
||||
{
|
||||
char *s;
|
||||
|
||||
depth++;
|
||||
depth++;
|
||||
|
||||
# define DUMP(HEADER) \
|
||||
for (i=0; i < depth; i++) \
|
||||
PR_Write(stream, " ", 2); \
|
||||
s = MimeHeaders_get (msg->hdrs, HEADER, PR_FALSE, PR_TRUE);
|
||||
for (i=0; i < depth; i++) \
|
||||
PR_Write(stream, " ", 2); \
|
||||
s = MimeHeaders_get (msg->hdrs, HEADER, PR_FALSE, PR_TRUE);
|
||||
/**
|
||||
\
|
||||
PR_Write(stream, HEADER ": %s\n", s ? s : ""); \
|
||||
PR_Write(stream, HEADER ": %s\n", s ? s : ""); \
|
||||
**/
|
||||
|
||||
PR_FREEIF(s)
|
||||
PR_FREEIF(s)
|
||||
|
||||
DUMP(HEADER_SUBJECT);
|
||||
DUMP(HEADER_DATE);
|
||||
@@ -908,17 +907,17 @@ MimeMessage_debug_print (MimeObject *obj, PRFileDesc *stream, PRInt32 depth)
|
||||
DUMP(HEADER_MESSAGE_ID);
|
||||
# undef DUMP
|
||||
|
||||
PR_Write(stream, "\n", 1);
|
||||
}
|
||||
PR_Write(stream, "\n", 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
PR_ASSERT(msg->container.nchildren <= 1);
|
||||
if (msg->container.nchildren == 1)
|
||||
{
|
||||
MimeObject *kid = msg->container.children[0];
|
||||
int status = kid->clazz->debug_print (kid, stream, depth+1);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
{
|
||||
MimeObject *kid = msg->container.children[0];
|
||||
int status = kid->clazz->debug_print (kid, stream, depth+1);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -50,14 +50,14 @@
|
||||
|
||||
#define MIME_SUPERCLASS mimeMultipartClass
|
||||
MimeDefClass(MimeMultipartSigned, MimeMultipartSignedClass,
|
||||
mimeMultipartSignedClass, &MIME_SUPERCLASS);
|
||||
mimeMultipartSignedClass, &MIME_SUPERCLASS);
|
||||
|
||||
static int MimeMultipartSigned_initialize (MimeObject *);
|
||||
static int MimeMultipartSigned_create_child (MimeObject *);
|
||||
static int MimeMultipartSigned_close_child(MimeObject *);
|
||||
static int MimeMultipartSigned_parse_line (const char *, PRInt32, MimeObject *);
|
||||
static int MimeMultipartSigned_parse_child_line (MimeObject *, const char *, PRInt32,
|
||||
PRBool);
|
||||
PRBool);
|
||||
static int MimeMultipartSigned_parse_eof (MimeObject *, PRBool);
|
||||
static void MimeMultipartSigned_finalize (MimeObject *);
|
||||
|
||||
@@ -100,20 +100,20 @@ MimeMultipartSigned_cleanup (MimeObject *obj, PRBool finalizing_p)
|
||||
MimeMultipart *mult = (MimeMultipart *) obj; /* #58075. Fix suggested by jwz */
|
||||
MimeMultipartSigned *sig = (MimeMultipartSigned *) obj;
|
||||
if (sig->part_buffer)
|
||||
{
|
||||
MimePartBufferDestroy(sig->part_buffer);
|
||||
sig->part_buffer = 0;
|
||||
}
|
||||
{
|
||||
MimePartBufferDestroy(sig->part_buffer);
|
||||
sig->part_buffer = 0;
|
||||
}
|
||||
if (sig->body_hdrs)
|
||||
{
|
||||
MimeHeaders_free (sig->body_hdrs);
|
||||
sig->body_hdrs = 0;
|
||||
}
|
||||
{
|
||||
MimeHeaders_free (sig->body_hdrs);
|
||||
sig->body_hdrs = 0;
|
||||
}
|
||||
if (sig->sig_hdrs)
|
||||
{
|
||||
MimeHeaders_free (sig->sig_hdrs);
|
||||
sig->sig_hdrs = 0;
|
||||
}
|
||||
{
|
||||
MimeHeaders_free (sig->sig_hdrs);
|
||||
sig->sig_hdrs = 0;
|
||||
}
|
||||
|
||||
mult->state = MimeMultipartEpilogue; /* #58075. Fix suggested by jwz */
|
||||
sig->state = MimeMultipartSignedEpilogue;
|
||||
@@ -127,10 +127,10 @@ MimeMultipartSigned_cleanup (MimeObject *obj, PRBool finalizing_p)
|
||||
}
|
||||
|
||||
if (sig->sig_decoder_data)
|
||||
{
|
||||
MimeDecoderDestroy(sig->sig_decoder_data, PR_TRUE);
|
||||
sig->sig_decoder_data = 0;
|
||||
}
|
||||
{
|
||||
MimeDecoderDestroy(sig->sig_decoder_data, PR_TRUE);
|
||||
sig->sig_decoder_data = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -144,23 +144,23 @@ MimeMultipartSigned_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
/* Close off the signature, if we've gotten that far.
|
||||
*/
|
||||
if (sig->state == MimeMultipartSignedSignatureHeaders ||
|
||||
sig->state == MimeMultipartSignedSignatureFirstLine ||
|
||||
sig->state == MimeMultipartSignedSignatureLine ||
|
||||
sig->state == MimeMultipartSignedEpilogue)
|
||||
{
|
||||
sig->state == MimeMultipartSignedSignatureFirstLine ||
|
||||
sig->state == MimeMultipartSignedSignatureLine ||
|
||||
sig->state == MimeMultipartSignedEpilogue)
|
||||
{
|
||||
status = (((MimeMultipartSignedClass *) obj->clazz)->crypto_signature_eof) (sig->crypto_closure, abort_p);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
}
|
||||
|
||||
if (!abort_p)
|
||||
{
|
||||
/* Now that we've read both the signed object and the signature (and
|
||||
have presumably verified the signature) write out a blurb, and then
|
||||
the signed object.
|
||||
*/
|
||||
status = MimeMultipartSigned_emit_child(obj);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
{
|
||||
/* Now that we've read both the signed object and the signature (and
|
||||
have presumably verified the signature) write out a blurb, and then
|
||||
the signed object.
|
||||
*/
|
||||
status = MimeMultipartSigned_emit_child(obj);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
|
||||
MimeMultipartSigned_cleanup(obj, PR_FALSE);
|
||||
return ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_eof(obj, abort_p);
|
||||
@@ -186,277 +186,277 @@ MimeMultipartSigned_parse_line (const char *line, PRInt32 length, MimeObject *ob
|
||||
int status = 0;
|
||||
|
||||
/* First do the parsing for normal multipart/ objects by handing it off to
|
||||
the superclass method. This includes calling the create_child and
|
||||
close_child methods.
|
||||
the superclass method. This includes calling the create_child and
|
||||
close_child methods.
|
||||
*/
|
||||
status = (((MimeObjectClass *)(&MIME_SUPERCLASS))
|
||||
->parse_line (line, length, obj));
|
||||
->parse_line (line, length, obj));
|
||||
if (status < 0) return status;
|
||||
|
||||
/* The instance variable MimeMultipartClass->state tracks motion through
|
||||
the various stages of multipart/ parsing. The instance variable
|
||||
MimeMultipartSigned->state tracks the difference between the first
|
||||
part (the body) and the second part (the signature.) This second,
|
||||
more specific state variable is updated by noticing the transitions
|
||||
of the first, more general state variable.
|
||||
the various stages of multipart/ parsing. The instance variable
|
||||
MimeMultipartSigned->state tracks the difference between the first
|
||||
part (the body) and the second part (the signature.) This second,
|
||||
more specific state variable is updated by noticing the transitions
|
||||
of the first, more general state variable.
|
||||
*/
|
||||
if (old_state != mult->state) /* there has been a state change */
|
||||
{
|
||||
switch (mult->state)
|
||||
{
|
||||
case MimeMultipartPreamble:
|
||||
PR_ASSERT(0); /* can't move *in* to preamble state. */
|
||||
sig->state = MimeMultipartSignedPreamble;
|
||||
break;
|
||||
{
|
||||
switch (mult->state)
|
||||
{
|
||||
case MimeMultipartPreamble:
|
||||
PR_ASSERT(0); /* can't move *in* to preamble state. */
|
||||
sig->state = MimeMultipartSignedPreamble;
|
||||
break;
|
||||
|
||||
case MimeMultipartHeaders:
|
||||
/* If we're moving in to the Headers state, then that means
|
||||
that this line is the preceeding boundary string (and we
|
||||
should ignore it.)
|
||||
*/
|
||||
hash_line_p = PR_FALSE;
|
||||
case MimeMultipartHeaders:
|
||||
/* If we're moving in to the Headers state, then that means
|
||||
that this line is the preceeding boundary string (and we
|
||||
should ignore it.)
|
||||
*/
|
||||
hash_line_p = PR_FALSE;
|
||||
|
||||
if (sig->state == MimeMultipartSignedPreamble)
|
||||
sig->state = MimeMultipartSignedBodyFirstHeader;
|
||||
else if (sig->state == MimeMultipartSignedBodyFirstLine ||
|
||||
sig->state == MimeMultipartSignedBodyLine)
|
||||
sig->state = MimeMultipartSignedSignatureHeaders;
|
||||
else if (sig->state == MimeMultipartSignedSignatureFirstLine ||
|
||||
sig->state == MimeMultipartSignedSignatureLine)
|
||||
sig->state = MimeMultipartSignedEpilogue;
|
||||
break;
|
||||
if (sig->state == MimeMultipartSignedPreamble)
|
||||
sig->state = MimeMultipartSignedBodyFirstHeader;
|
||||
else if (sig->state == MimeMultipartSignedBodyFirstLine ||
|
||||
sig->state == MimeMultipartSignedBodyLine)
|
||||
sig->state = MimeMultipartSignedSignatureHeaders;
|
||||
else if (sig->state == MimeMultipartSignedSignatureFirstLine ||
|
||||
sig->state == MimeMultipartSignedSignatureLine)
|
||||
sig->state = MimeMultipartSignedEpilogue;
|
||||
break;
|
||||
|
||||
case MimeMultipartPartFirstLine:
|
||||
if (sig->state == MimeMultipartSignedBodyFirstHeader)
|
||||
{
|
||||
sig->state = MimeMultipartSignedBodyFirstLine;
|
||||
no_headers_p = PR_TRUE;
|
||||
}
|
||||
else if (sig->state == MimeMultipartSignedBodyHeaders)
|
||||
sig->state = MimeMultipartSignedBodyFirstLine;
|
||||
else if (sig->state == MimeMultipartSignedSignatureHeaders)
|
||||
sig->state = MimeMultipartSignedSignatureFirstLine;
|
||||
else
|
||||
sig->state = MimeMultipartSignedEpilogue;
|
||||
break;
|
||||
case MimeMultipartPartFirstLine:
|
||||
if (sig->state == MimeMultipartSignedBodyFirstHeader)
|
||||
{
|
||||
sig->state = MimeMultipartSignedBodyFirstLine;
|
||||
no_headers_p = PR_TRUE;
|
||||
}
|
||||
else if (sig->state == MimeMultipartSignedBodyHeaders)
|
||||
sig->state = MimeMultipartSignedBodyFirstLine;
|
||||
else if (sig->state == MimeMultipartSignedSignatureHeaders)
|
||||
sig->state = MimeMultipartSignedSignatureFirstLine;
|
||||
else
|
||||
sig->state = MimeMultipartSignedEpilogue;
|
||||
break;
|
||||
|
||||
case MimeMultipartPartLine:
|
||||
case MimeMultipartPartLine:
|
||||
|
||||
PR_ASSERT(sig->state == MimeMultipartSignedBodyFirstLine ||
|
||||
sig->state == MimeMultipartSignedBodyLine ||
|
||||
sig->state == MimeMultipartSignedSignatureFirstLine ||
|
||||
sig->state == MimeMultipartSignedSignatureLine);
|
||||
PR_ASSERT(sig->state == MimeMultipartSignedBodyFirstLine ||
|
||||
sig->state == MimeMultipartSignedBodyLine ||
|
||||
sig->state == MimeMultipartSignedSignatureFirstLine ||
|
||||
sig->state == MimeMultipartSignedSignatureLine);
|
||||
|
||||
if (sig->state == MimeMultipartSignedBodyFirstLine)
|
||||
sig->state = MimeMultipartSignedBodyLine;
|
||||
else if (sig->state == MimeMultipartSignedSignatureFirstLine)
|
||||
sig->state = MimeMultipartSignedSignatureLine;
|
||||
break;
|
||||
if (sig->state == MimeMultipartSignedBodyFirstLine)
|
||||
sig->state = MimeMultipartSignedBodyLine;
|
||||
else if (sig->state == MimeMultipartSignedSignatureFirstLine)
|
||||
sig->state = MimeMultipartSignedSignatureLine;
|
||||
break;
|
||||
|
||||
case MimeMultipartEpilogue:
|
||||
sig->state = MimeMultipartSignedEpilogue;
|
||||
break;
|
||||
case MimeMultipartEpilogue:
|
||||
sig->state = MimeMultipartSignedEpilogue;
|
||||
break;
|
||||
|
||||
default: /* bad state */
|
||||
PR_ASSERT(0);
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
default: /* bad state */
|
||||
PR_ASSERT(0);
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Perform multipart/signed-related actions on this line based on the state
|
||||
of the parser.
|
||||
of the parser.
|
||||
*/
|
||||
switch (sig->state)
|
||||
{
|
||||
case MimeMultipartSignedPreamble:
|
||||
/* Do nothing. */
|
||||
break;
|
||||
{
|
||||
case MimeMultipartSignedPreamble:
|
||||
/* Do nothing. */
|
||||
break;
|
||||
|
||||
case MimeMultipartSignedBodyFirstLine:
|
||||
/* We have just moved out of the MimeMultipartSignedBodyHeaders
|
||||
state, so cache away the headers that apply only to the body part.
|
||||
*/
|
||||
PR_ASSERT(mult->hdrs);
|
||||
PR_ASSERT(!sig->body_hdrs);
|
||||
sig->body_hdrs = mult->hdrs;
|
||||
mult->hdrs = 0;
|
||||
case MimeMultipartSignedBodyFirstLine:
|
||||
/* We have just moved out of the MimeMultipartSignedBodyHeaders
|
||||
state, so cache away the headers that apply only to the body part.
|
||||
*/
|
||||
PR_ASSERT(mult->hdrs);
|
||||
PR_ASSERT(!sig->body_hdrs);
|
||||
sig->body_hdrs = mult->hdrs;
|
||||
mult->hdrs = 0;
|
||||
|
||||
/* fall through. */
|
||||
/* fall through. */
|
||||
|
||||
case MimeMultipartSignedBodyFirstHeader:
|
||||
case MimeMultipartSignedBodyHeaders:
|
||||
case MimeMultipartSignedBodyLine:
|
||||
case MimeMultipartSignedBodyFirstHeader:
|
||||
case MimeMultipartSignedBodyHeaders:
|
||||
case MimeMultipartSignedBodyLine:
|
||||
|
||||
if (!sig->crypto_closure)
|
||||
{
|
||||
/* Set error change */
|
||||
PR_SetError(0, 0);
|
||||
/* Initialize the signature verification library. */
|
||||
sig->crypto_closure = (((MimeMultipartSignedClass *) obj->clazz)
|
||||
->crypto_init) (obj);
|
||||
if (!sig->crypto_closure)
|
||||
{
|
||||
status = PR_GetError();
|
||||
PR_ASSERT(status < 0);
|
||||
if (status >= 0) status = -1;
|
||||
return status;
|
||||
}
|
||||
}
|
||||
if (!sig->crypto_closure)
|
||||
{
|
||||
/* Set error change */
|
||||
PR_SetError(0, 0);
|
||||
/* Initialize the signature verification library. */
|
||||
sig->crypto_closure = (((MimeMultipartSignedClass *) obj->clazz)
|
||||
->crypto_init) (obj);
|
||||
if (!sig->crypto_closure)
|
||||
{
|
||||
status = PR_GetError();
|
||||
PR_ASSERT(status < 0);
|
||||
if (status >= 0) status = -1;
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
if (hash_line_p)
|
||||
{
|
||||
/* this is the first hashed line if this is the first header
|
||||
(that is, if it's the first line in the header state after
|
||||
a state change.)
|
||||
*/
|
||||
PRBool first_line_p
|
||||
= (no_headers_p ||
|
||||
sig->state == MimeMultipartSignedBodyFirstHeader);
|
||||
if (hash_line_p)
|
||||
{
|
||||
/* this is the first hashed line if this is the first header
|
||||
(that is, if it's the first line in the header state after
|
||||
a state change.)
|
||||
*/
|
||||
PRBool first_line_p
|
||||
= (no_headers_p ||
|
||||
sig->state == MimeMultipartSignedBodyFirstHeader);
|
||||
|
||||
if (sig->state == MimeMultipartSignedBodyFirstHeader)
|
||||
sig->state = MimeMultipartSignedBodyHeaders;
|
||||
if (sig->state == MimeMultipartSignedBodyFirstHeader)
|
||||
sig->state = MimeMultipartSignedBodyHeaders;
|
||||
|
||||
/* The newline issues here are tricky, since both the newlines
|
||||
before and after the boundary string are to be considered part
|
||||
of the boundary: this is so that a part can be specified such
|
||||
that it does not end in a trailing newline.
|
||||
/* The newline issues here are tricky, since both the newlines
|
||||
before and after the boundary string are to be considered part
|
||||
of the boundary: this is so that a part can be specified such
|
||||
that it does not end in a trailing newline.
|
||||
|
||||
To implement this, we send a newline *before* each line instead
|
||||
of after, except for the first line, which is not preceeded by a
|
||||
newline.
|
||||
To implement this, we send a newline *before* each line instead
|
||||
of after, except for the first line, which is not preceeded by a
|
||||
newline.
|
||||
|
||||
For purposes of cryptographic hashing, we always hash line
|
||||
breaks as CRLF -- the canonical, on-the-wire linebreaks, since
|
||||
we have no idea of knowing what line breaks were used on the
|
||||
originating system (SMTP rightly destroys that information.)
|
||||
*/
|
||||
For purposes of cryptographic hashing, we always hash line
|
||||
breaks as CRLF -- the canonical, on-the-wire linebreaks, since
|
||||
we have no idea of knowing what line breaks were used on the
|
||||
originating system (SMTP rightly destroys that information.)
|
||||
*/
|
||||
|
||||
/* Remove the trailing newline... */
|
||||
if (length > 0 && line[length-1] == '\n') length--;
|
||||
if (length > 0 && line[length-1] == '\r') length--;
|
||||
/* Remove the trailing newline... */
|
||||
if (length > 0 && line[length-1] == '\n') length--;
|
||||
if (length > 0 && line[length-1] == '\r') length--;
|
||||
|
||||
PR_ASSERT(sig->crypto_closure);
|
||||
PR_ASSERT(sig->crypto_closure);
|
||||
|
||||
if (!first_line_p)
|
||||
{
|
||||
/* Push out a preceeding newline... */
|
||||
char nl[] = CRLF;
|
||||
status = (((MimeMultipartSignedClass *) obj->clazz)
|
||||
->crypto_data_hash (nl, 2, sig->crypto_closure));
|
||||
if (status < 0) return status;
|
||||
}
|
||||
if (!first_line_p)
|
||||
{
|
||||
/* Push out a preceeding newline... */
|
||||
char nl[] = CRLF;
|
||||
status = (((MimeMultipartSignedClass *) obj->clazz)
|
||||
->crypto_data_hash (nl, 2, sig->crypto_closure));
|
||||
if (status < 0) return status;
|
||||
}
|
||||
|
||||
/* Now push out the line sans trailing newline. */
|
||||
if (length > 0)
|
||||
status = (((MimeMultipartSignedClass *) obj->clazz)
|
||||
->crypto_data_hash (line,length, sig->crypto_closure));
|
||||
if (status < 0) return status;
|
||||
}
|
||||
break;
|
||||
/* Now push out the line sans trailing newline. */
|
||||
if (length > 0)
|
||||
status = (((MimeMultipartSignedClass *) obj->clazz)
|
||||
->crypto_data_hash (line,length, sig->crypto_closure));
|
||||
if (status < 0) return status;
|
||||
}
|
||||
break;
|
||||
|
||||
case MimeMultipartSignedSignatureHeaders:
|
||||
case MimeMultipartSignedSignatureHeaders:
|
||||
|
||||
if (sig->crypto_closure &&
|
||||
old_state != mult->state)
|
||||
{
|
||||
/* We have just moved out of the MimeMultipartSignedBodyLine
|
||||
state, so tell the signature verification library that we've
|
||||
reached the end of the signed data.
|
||||
*/
|
||||
status = (((MimeMultipartSignedClass *) obj->clazz)
|
||||
->crypto_data_eof) (sig->crypto_closure, PR_FALSE);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
break;
|
||||
if (sig->crypto_closure &&
|
||||
old_state != mult->state)
|
||||
{
|
||||
/* We have just moved out of the MimeMultipartSignedBodyLine
|
||||
state, so tell the signature verification library that we've
|
||||
reached the end of the signed data.
|
||||
*/
|
||||
status = (((MimeMultipartSignedClass *) obj->clazz)
|
||||
->crypto_data_eof) (sig->crypto_closure, PR_FALSE);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
break;
|
||||
|
||||
case MimeMultipartSignedSignatureFirstLine:
|
||||
/* We have just moved out of the MimeMultipartSignedSignatureHeaders
|
||||
state, so cache away the headers that apply only to the sig part.
|
||||
*/
|
||||
PR_ASSERT(mult->hdrs);
|
||||
PR_ASSERT(!sig->sig_hdrs);
|
||||
sig->sig_hdrs = mult->hdrs;
|
||||
mult->hdrs = 0;
|
||||
case MimeMultipartSignedSignatureFirstLine:
|
||||
/* We have just moved out of the MimeMultipartSignedSignatureHeaders
|
||||
state, so cache away the headers that apply only to the sig part.
|
||||
*/
|
||||
PR_ASSERT(mult->hdrs);
|
||||
PR_ASSERT(!sig->sig_hdrs);
|
||||
sig->sig_hdrs = mult->hdrs;
|
||||
mult->hdrs = 0;
|
||||
|
||||
|
||||
/* If the signature block has an encoding, set up a decoder for it.
|
||||
(Similar logic is in MimeLeafClass->parse_begin.)
|
||||
*/
|
||||
{
|
||||
MimeDecoderData *(*fn) (nsresult (*) (const char*, PRInt32,void*), void*) = 0;
|
||||
/* If the signature block has an encoding, set up a decoder for it.
|
||||
(Similar logic is in MimeLeafClass->parse_begin.)
|
||||
*/
|
||||
{
|
||||
MimeDecoderData *(*fn) (nsresult (*) (const char*, PRInt32,void*), void*) = 0;
|
||||
nsCString encoding;
|
||||
encoding.Adopt(MimeHeaders_get (sig->sig_hdrs,
|
||||
HEADER_CONTENT_TRANSFER_ENCODING,
|
||||
PR_TRUE, PR_FALSE));
|
||||
if (encoding.IsEmpty())
|
||||
;
|
||||
else if (!nsCRT::strcasecmp(encoding.get(), ENCODING_BASE64))
|
||||
else if (!PL_strcasecmp(encoding.get(), ENCODING_BASE64))
|
||||
fn = &MimeB64DecoderInit;
|
||||
else if (!nsCRT::strcasecmp(encoding.get(), ENCODING_QUOTED_PRINTABLE))
|
||||
else if (!PL_strcasecmp(encoding.get(), ENCODING_QUOTED_PRINTABLE))
|
||||
{
|
||||
sig->sig_decoder_data =
|
||||
MimeQPDecoderInit (((nsresult (*) (const char *, PRInt32, void *))
|
||||
(((MimeMultipartSignedClass *) obj->clazz)
|
||||
->crypto_signature_hash)),
|
||||
sig->crypto_closure);
|
||||
MimeQPDecoderInit (((nsresult (*) (const char *, PRInt32, void *))
|
||||
(((MimeMultipartSignedClass *) obj->clazz)
|
||||
->crypto_signature_hash)),
|
||||
sig->crypto_closure);
|
||||
if (!sig->sig_decoder_data)
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
else if (!nsCRT::strcasecmp(encoding.get(), ENCODING_UUENCODE) ||
|
||||
!nsCRT::strcasecmp(encoding.get(), ENCODING_UUENCODE2) ||
|
||||
!nsCRT::strcasecmp(encoding.get(), ENCODING_UUENCODE3) ||
|
||||
!nsCRT::strcasecmp(encoding.get(), ENCODING_UUENCODE4))
|
||||
else if (!PL_strcasecmp(encoding.get(), ENCODING_UUENCODE) ||
|
||||
!PL_strcasecmp(encoding.get(), ENCODING_UUENCODE2) ||
|
||||
!PL_strcasecmp(encoding.get(), ENCODING_UUENCODE3) ||
|
||||
!PL_strcasecmp(encoding.get(), ENCODING_UUENCODE4))
|
||||
fn = &MimeUUDecoderInit;
|
||||
else if (!nsCRT::strcasecmp(encoding.get(), ENCODING_YENCODE))
|
||||
else if (!PL_strcasecmp(encoding.get(), ENCODING_YENCODE))
|
||||
fn = &MimeYDecoderInit;
|
||||
if (fn)
|
||||
{
|
||||
sig->sig_decoder_data =
|
||||
fn (((nsresult (*) (const char *, PRInt32, void *))
|
||||
(((MimeMultipartSignedClass *) obj->clazz)
|
||||
->crypto_signature_hash)),
|
||||
sig->crypto_closure);
|
||||
if (!sig->sig_decoder_data)
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
if (fn)
|
||||
{
|
||||
sig->sig_decoder_data =
|
||||
fn (((nsresult (*) (const char *, PRInt32, void *))
|
||||
(((MimeMultipartSignedClass *) obj->clazz)
|
||||
->crypto_signature_hash)),
|
||||
sig->crypto_closure);
|
||||
if (!sig->sig_decoder_data)
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
/* Show these headers to the crypto module. */
|
||||
if (hash_line_p)
|
||||
{
|
||||
status = (((MimeMultipartSignedClass *) obj->clazz)
|
||||
->crypto_signature_init) (sig->crypto_closure,
|
||||
obj, sig->sig_hdrs);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
/* Show these headers to the crypto module. */
|
||||
if (hash_line_p)
|
||||
{
|
||||
status = (((MimeMultipartSignedClass *) obj->clazz)
|
||||
->crypto_signature_init) (sig->crypto_closure,
|
||||
obj, sig->sig_hdrs);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
|
||||
/* fall through. */
|
||||
/* fall through. */
|
||||
|
||||
case MimeMultipartSignedSignatureLine:
|
||||
if (hash_line_p)
|
||||
{
|
||||
/* Feed this line into the signature verification routines. */
|
||||
case MimeMultipartSignedSignatureLine:
|
||||
if (hash_line_p)
|
||||
{
|
||||
/* Feed this line into the signature verification routines. */
|
||||
|
||||
if (sig->sig_decoder_data)
|
||||
status = MimeDecoderWrite (sig->sig_decoder_data, line, length);
|
||||
else
|
||||
status = (((MimeMultipartSignedClass *) obj->clazz)
|
||||
->crypto_signature_hash (line, length,
|
||||
sig->crypto_closure));
|
||||
if (status < 0) return status;
|
||||
}
|
||||
break;
|
||||
if (sig->sig_decoder_data)
|
||||
status = MimeDecoderWrite (sig->sig_decoder_data, line, length);
|
||||
else
|
||||
status = (((MimeMultipartSignedClass *) obj->clazz)
|
||||
->crypto_signature_hash (line, length,
|
||||
sig->crypto_closure));
|
||||
if (status < 0) return status;
|
||||
}
|
||||
break;
|
||||
|
||||
case MimeMultipartSignedEpilogue:
|
||||
/* Nothing special to do here. */
|
||||
break;
|
||||
case MimeMultipartSignedEpilogue:
|
||||
/* Nothing special to do here. */
|
||||
break;
|
||||
|
||||
default: /* bad state */
|
||||
PR_ASSERT(0);
|
||||
return -1;
|
||||
}
|
||||
default: /* bad state */
|
||||
PR_ASSERT(0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -466,8 +466,8 @@ static int
|
||||
MimeMultipartSigned_create_child (MimeObject *parent)
|
||||
{
|
||||
/* Don't actually create a child -- we call the superclass create_child
|
||||
method later, after we've fully parsed everything. (And we only call
|
||||
it once, for part #1, and never for part #2 (the signature.))
|
||||
method later, after we've fully parsed everything. (And we only call
|
||||
it once, for part #1, and never for part #2 (the signature.))
|
||||
*/
|
||||
MimeMultipart *mult = (MimeMultipart *) parent;
|
||||
mult->state = MimeMultipartPartFirstLine;
|
||||
@@ -479,22 +479,22 @@ static int
|
||||
MimeMultipartSigned_close_child (MimeObject *obj)
|
||||
{
|
||||
/* The close_child method on MimeMultipartSigned doesn't actually do
|
||||
anything to the children list, since the create_child method also
|
||||
doesn't do anything.
|
||||
anything to the children list, since the create_child method also
|
||||
doesn't do anything.
|
||||
*/
|
||||
MimeMultipart *mult = (MimeMultipart *) obj;
|
||||
MimeContainer *cont = (MimeContainer *) obj;
|
||||
MimeMultipartSigned *msig = (MimeMultipartSigned *) obj;
|
||||
|
||||
if (msig->part_buffer)
|
||||
/* Closes the tmp file, if there is one: doesn't free the part_buffer. */
|
||||
MimePartBufferClose(msig->part_buffer);
|
||||
/* Closes the tmp file, if there is one: doesn't free the part_buffer. */
|
||||
MimePartBufferClose(msig->part_buffer);
|
||||
|
||||
if (mult->hdrs) /* duplicated from MimeMultipart_close_child, ugh. */
|
||||
{
|
||||
MimeHeaders_free(mult->hdrs);
|
||||
mult->hdrs = 0;
|
||||
}
|
||||
if (mult->hdrs) /* duplicated from MimeMultipart_close_child, ugh. */
|
||||
{
|
||||
MimeHeaders_free(mult->hdrs);
|
||||
mult->hdrs = 0;
|
||||
}
|
||||
|
||||
/* Should be no kids yet. */
|
||||
PR_ASSERT(cont->nchildren == 0);
|
||||
@@ -506,8 +506,8 @@ MimeMultipartSigned_close_child (MimeObject *obj)
|
||||
|
||||
static int
|
||||
MimeMultipartSigned_parse_child_line (MimeObject *obj,
|
||||
const char *line, PRInt32 length,
|
||||
PRBool first_line_p)
|
||||
const char *line, PRInt32 length,
|
||||
PRBool first_line_p)
|
||||
{
|
||||
MimeMultipartSigned *sig = (MimeMultipartSigned *) obj;
|
||||
MimeContainer *cont = (MimeContainer *) obj;
|
||||
@@ -518,84 +518,84 @@ MimeMultipartSigned_parse_child_line (MimeObject *obj,
|
||||
if (cont->nchildren != 0) return -1;
|
||||
|
||||
switch (sig->state)
|
||||
{
|
||||
case MimeMultipartSignedPreamble:
|
||||
case MimeMultipartSignedBodyFirstHeader:
|
||||
case MimeMultipartSignedBodyHeaders:
|
||||
PR_ASSERT(0); /* How'd we get here? Oh well, fall through. */
|
||||
{
|
||||
case MimeMultipartSignedPreamble:
|
||||
case MimeMultipartSignedBodyFirstHeader:
|
||||
case MimeMultipartSignedBodyHeaders:
|
||||
PR_ASSERT(0); /* How'd we get here? Oh well, fall through. */
|
||||
|
||||
case MimeMultipartSignedBodyFirstLine:
|
||||
PR_ASSERT(first_line_p);
|
||||
if (!sig->part_buffer)
|
||||
{
|
||||
sig->part_buffer = MimePartBufferCreate();
|
||||
if (!sig->part_buffer)
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
/* fall through */
|
||||
case MimeMultipartSignedBodyFirstLine:
|
||||
PR_ASSERT(first_line_p);
|
||||
if (!sig->part_buffer)
|
||||
{
|
||||
sig->part_buffer = MimePartBufferCreate();
|
||||
if (!sig->part_buffer)
|
||||
return MIME_OUT_OF_MEMORY;
|
||||
}
|
||||
/* fall through */
|
||||
|
||||
case MimeMultipartSignedBodyLine:
|
||||
{
|
||||
/* This is the first part; we are buffering it, and will emit it all
|
||||
at the end (so that we know whether the signature matches before
|
||||
showing anything to the user.)
|
||||
*/
|
||||
case MimeMultipartSignedBodyLine:
|
||||
{
|
||||
/* This is the first part; we are buffering it, and will emit it all
|
||||
at the end (so that we know whether the signature matches before
|
||||
showing anything to the user.)
|
||||
*/
|
||||
|
||||
/* The newline issues here are tricky, since both the newlines
|
||||
before and after the boundary string are to be considered part
|
||||
of the boundary: this is so that a part can be specified such
|
||||
that it does not end in a trailing newline.
|
||||
/* The newline issues here are tricky, since both the newlines
|
||||
before and after the boundary string are to be considered part
|
||||
of the boundary: this is so that a part can be specified such
|
||||
that it does not end in a trailing newline.
|
||||
|
||||
To implement this, we send a newline *before* each line instead
|
||||
of after, except for the first line, which is not preceeded by a
|
||||
newline.
|
||||
*/
|
||||
To implement this, we send a newline *before* each line instead
|
||||
of after, except for the first line, which is not preceeded by a
|
||||
newline.
|
||||
*/
|
||||
|
||||
/* Remove the trailing newline... */
|
||||
if (length > 0 && line[length-1] == '\n') length--;
|
||||
if (length > 0 && line[length-1] == '\r') length--;
|
||||
/* Remove the trailing newline... */
|
||||
if (length > 0 && line[length-1] == '\n') length--;
|
||||
if (length > 0 && line[length-1] == '\r') length--;
|
||||
|
||||
PR_ASSERT(sig->part_buffer);
|
||||
PR_ASSERT(first_line_p ==
|
||||
(sig->state == MimeMultipartSignedBodyFirstLine));
|
||||
PR_ASSERT(sig->part_buffer);
|
||||
PR_ASSERT(first_line_p ==
|
||||
(sig->state == MimeMultipartSignedBodyFirstLine));
|
||||
|
||||
if (!first_line_p)
|
||||
{
|
||||
/* Push out a preceeding newline... */
|
||||
char nl[] = MSG_LINEBREAK;
|
||||
status = MimePartBufferWrite (sig->part_buffer, nl, MSG_LINEBREAK_LEN);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
if (!first_line_p)
|
||||
{
|
||||
/* Push out a preceeding newline... */
|
||||
char nl[] = MSG_LINEBREAK;
|
||||
status = MimePartBufferWrite (sig->part_buffer, nl, MSG_LINEBREAK_LEN);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
|
||||
/* Now push out the line sans trailing newline. */
|
||||
if (length > 0)
|
||||
status = MimePartBufferWrite (sig->part_buffer, line, length);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
break;
|
||||
/* Now push out the line sans trailing newline. */
|
||||
if (length > 0)
|
||||
status = MimePartBufferWrite (sig->part_buffer, line, length);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
break;
|
||||
|
||||
case MimeMultipartSignedSignatureHeaders:
|
||||
PR_ASSERT(0); /* How'd we get here? Oh well, fall through. */
|
||||
case MimeMultipartSignedSignatureHeaders:
|
||||
PR_ASSERT(0); /* How'd we get here? Oh well, fall through. */
|
||||
|
||||
case MimeMultipartSignedSignatureFirstLine:
|
||||
case MimeMultipartSignedSignatureLine:
|
||||
/* Nothing to do here -- hashing of the signature part is handled up
|
||||
in MimeMultipartSigned_parse_line().
|
||||
*/
|
||||
break;
|
||||
case MimeMultipartSignedSignatureFirstLine:
|
||||
case MimeMultipartSignedSignatureLine:
|
||||
/* Nothing to do here -- hashing of the signature part is handled up
|
||||
in MimeMultipartSigned_parse_line().
|
||||
*/
|
||||
break;
|
||||
|
||||
case MimeMultipartSignedEpilogue:
|
||||
/* Too many kids? MimeMultipartSigned_create_child() should have
|
||||
prevented us from getting here. */
|
||||
PR_ASSERT(0);
|
||||
return -1;
|
||||
break;
|
||||
case MimeMultipartSignedEpilogue:
|
||||
/* Too many kids? MimeMultipartSigned_create_child() should have
|
||||
prevented us from getting here. */
|
||||
PR_ASSERT(0);
|
||||
return -1;
|
||||
break;
|
||||
|
||||
default: /* bad state */
|
||||
PR_ASSERT(0);
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
default: /* bad state */
|
||||
PR_ASSERT(0);
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -613,62 +613,62 @@ MimeMultipartSigned_emit_child (MimeObject *obj)
|
||||
NS_ASSERTION(sig->crypto_closure, "no crypto closure");
|
||||
|
||||
/* Emit some HTML saying whether the signature was cool.
|
||||
But don't emit anything if in FO_QUOTE_MESSAGE mode.
|
||||
But don't emit anything if in FO_QUOTE_MESSAGE mode.
|
||||
*/
|
||||
if (obj->options &&
|
||||
obj->options->headers != MimeHeadersCitation &&
|
||||
obj->options->write_html_p &&
|
||||
obj->options->output_fn &&
|
||||
obj->options->headers != MimeHeadersCitation &&
|
||||
sig->crypto_closure)
|
||||
{
|
||||
char *html = (((MimeMultipartSignedClass *) obj->clazz)
|
||||
->crypto_generate_html (sig->crypto_closure));
|
||||
obj->options->headers != MimeHeadersCitation &&
|
||||
obj->options->write_html_p &&
|
||||
obj->options->output_fn &&
|
||||
obj->options->headers != MimeHeadersCitation &&
|
||||
sig->crypto_closure)
|
||||
{
|
||||
char *html = (((MimeMultipartSignedClass *) obj->clazz)
|
||||
->crypto_generate_html (sig->crypto_closure));
|
||||
#if 0 // XXX For the moment, no HTML output. Fix this XXX //
|
||||
if (!html) return -1; /* MIME_OUT_OF_MEMORY? */
|
||||
if (!html) return -1; /* MIME_OUT_OF_MEMORY? */
|
||||
|
||||
status = MimeObject_write(obj, html, nsCRT::strlen(html), PR_FALSE);
|
||||
PR_Free(html);
|
||||
if (status < 0) return status;
|
||||
status = MimeObject_write(obj, html, strlen(html), PR_FALSE);
|
||||
PR_Free(html);
|
||||
if (status < 0) return status;
|
||||
#endif
|
||||
|
||||
/* Now that we have written out the crypto stamp, the outermost header
|
||||
block is well and truly closed. If this is in fact the outermost
|
||||
message, then run the post_header_html_fn now.
|
||||
*/
|
||||
if (obj->options &&
|
||||
obj->options->state &&
|
||||
obj->options->generate_post_header_html_fn &&
|
||||
!obj->options->state->post_header_html_run_p)
|
||||
{
|
||||
MimeHeaders *outer_headers=nsnull;
|
||||
MimeObject *p;
|
||||
for (p = obj; p->parent; p = p->parent)
|
||||
outer_headers = p->headers;
|
||||
PR_ASSERT(obj->options->state->first_data_written_p);
|
||||
html = obj->options->generate_post_header_html_fn(NULL,
|
||||
obj->options->html_closure,
|
||||
outer_headers);
|
||||
obj->options->state->post_header_html_run_p = PR_TRUE;
|
||||
if (html)
|
||||
{
|
||||
status = MimeObject_write(obj, html, strlen(html), PR_FALSE);
|
||||
PR_Free(html);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Now that we have written out the crypto stamp, the outermost header
|
||||
block is well and truly closed. If this is in fact the outermost
|
||||
message, then run the post_header_html_fn now.
|
||||
*/
|
||||
if (obj->options &&
|
||||
obj->options->state &&
|
||||
obj->options->generate_post_header_html_fn &&
|
||||
!obj->options->state->post_header_html_run_p)
|
||||
{
|
||||
MimeHeaders *outer_headers=nsnull;
|
||||
MimeObject *p;
|
||||
for (p = obj; p->parent; p = p->parent)
|
||||
outer_headers = p->headers;
|
||||
PR_ASSERT(obj->options->state->first_data_written_p);
|
||||
html = obj->options->generate_post_header_html_fn(NULL,
|
||||
obj->options->html_closure,
|
||||
outer_headers);
|
||||
obj->options->state->post_header_html_run_p = PR_TRUE;
|
||||
if (html)
|
||||
{
|
||||
status = MimeObject_write(obj, html, strlen(html), PR_FALSE);
|
||||
PR_Free(html);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Oh, this is fairly nasty. We're skipping over our "create child" method
|
||||
and using the one our superclass defines. Perhaps instead we should add
|
||||
a new method on this class, and initialize that method to be the
|
||||
create_child method of the superclass. Whatever.
|
||||
and using the one our superclass defines. Perhaps instead we should add
|
||||
a new method on this class, and initialize that method to be the
|
||||
create_child method of the superclass. Whatever.
|
||||
*/
|
||||
|
||||
|
||||
/* The superclass method expects to find the headers for the part that it's
|
||||
to create in mult->hdrs, so ensure that they're there. */
|
||||
to create in mult->hdrs, so ensure that they're there. */
|
||||
PR_ASSERT(!mult->hdrs);
|
||||
if (mult->hdrs) MimeHeaders_free(mult->hdrs);
|
||||
mult->hdrs = sig->body_hdrs;
|
||||
@@ -690,13 +690,13 @@ MimeMultipartSigned_emit_child (MimeObject *obj)
|
||||
if (!disposition)
|
||||
{
|
||||
const char *content_type = firstChild->content_type;
|
||||
if (!nsCRT::strcasecmp (content_type, TEXT_PLAIN) ||
|
||||
!nsCRT::strcasecmp (content_type, TEXT_HTML) ||
|
||||
!nsCRT::strcasecmp (content_type, TEXT_MDL) ||
|
||||
!nsCRT::strcasecmp (content_type, MULTIPART_ALTERNATIVE) ||
|
||||
!nsCRT::strcasecmp (content_type, MULTIPART_RELATED) ||
|
||||
!nsCRT::strcasecmp (content_type, MESSAGE_NEWS) ||
|
||||
!nsCRT::strcasecmp (content_type, MESSAGE_RFC822)) {
|
||||
if (!PL_strcasecmp (content_type, TEXT_PLAIN) ||
|
||||
!PL_strcasecmp (content_type, TEXT_HTML) ||
|
||||
!PL_strcasecmp (content_type, TEXT_MDL) ||
|
||||
!PL_strcasecmp (content_type, MULTIPART_ALTERNATIVE) ||
|
||||
!PL_strcasecmp (content_type, MULTIPART_RELATED) ||
|
||||
!PL_strcasecmp (content_type, MESSAGE_NEWS) ||
|
||||
!PL_strcasecmp (content_type, MESSAGE_RFC822)) {
|
||||
char *ct = MimeHeaders_get(mult->hdrs, HEADER_CONTENT_TYPE, PR_FALSE, PR_FALSE);
|
||||
if (ct) {
|
||||
char *cset = MimeHeaders_get_parameter (ct, "charset", NULL, NULL);
|
||||
@@ -721,37 +721,37 @@ MimeMultipartSigned_emit_child (MimeObject *obj)
|
||||
|
||||
#ifdef MIME_DRAFTS
|
||||
if (body->options->decompose_file_p) {
|
||||
body->options->signed_p = PR_TRUE;
|
||||
if (!mime_typep(body, (MimeObjectClass*)&mimeMultipartClass) &&
|
||||
body->options->decompose_file_init_fn)
|
||||
body->options->decompose_file_init_fn ( body->options->stream_closure, body->headers );
|
||||
body->options->signed_p = PR_TRUE;
|
||||
if (!mime_typep(body, (MimeObjectClass*)&mimeMultipartClass) &&
|
||||
body->options->decompose_file_init_fn)
|
||||
body->options->decompose_file_init_fn ( body->options->stream_closure, body->headers );
|
||||
}
|
||||
#endif /* MIME_DRAFTS */
|
||||
|
||||
/* If there's no part_buffer, this is a zero-length signed message? */
|
||||
if (sig->part_buffer)
|
||||
{
|
||||
{
|
||||
#ifdef MIME_DRAFTS
|
||||
if (body->options->decompose_file_p &&
|
||||
!mime_typep(body, (MimeObjectClass*)&mimeMultipartClass) &&
|
||||
body->options->decompose_file_output_fn)
|
||||
status = MimePartBufferRead (sig->part_buffer,
|
||||
/* The (nsresult (*) ...) cast is to turn the
|
||||
`void' argument into `MimeObject'. */
|
||||
((nsresult (*) (const char *, PRInt32, void *))
|
||||
body->options->decompose_file_output_fn),
|
||||
body->options->stream_closure);
|
||||
else
|
||||
if (body->options->decompose_file_p &&
|
||||
!mime_typep(body, (MimeObjectClass*)&mimeMultipartClass) &&
|
||||
body->options->decompose_file_output_fn)
|
||||
status = MimePartBufferRead (sig->part_buffer,
|
||||
/* The (nsresult (*) ...) cast is to turn the
|
||||
`void' argument into `MimeObject'. */
|
||||
((nsresult (*) (const char *, PRInt32, void *))
|
||||
body->options->decompose_file_output_fn),
|
||||
body->options->stream_closure);
|
||||
else
|
||||
#endif /* MIME_DRAFTS */
|
||||
|
||||
status = MimePartBufferRead (sig->part_buffer,
|
||||
/* The (nsresult (*) ...) cast is to turn the
|
||||
`void' argument into `MimeObject'. */
|
||||
((nsresult (*) (const char *, PRInt32, void *))
|
||||
body->clazz->parse_buffer),
|
||||
body);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
status = MimePartBufferRead (sig->part_buffer,
|
||||
/* The (nsresult (*) ...) cast is to turn the
|
||||
`void' argument into `MimeObject'. */
|
||||
((nsresult (*) (const char *, PRInt32, void *))
|
||||
body->clazz->parse_buffer),
|
||||
body);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
|
||||
MimeMultipartSigned_cleanup(obj, PR_FALSE);
|
||||
|
||||
@@ -763,9 +763,9 @@ MimeMultipartSigned_emit_child (MimeObject *obj)
|
||||
|
||||
#ifdef MIME_DRAFTS
|
||||
if (body->options->decompose_file_p &&
|
||||
!mime_typep(body, (MimeObjectClass*)&mimeMultipartClass) &&
|
||||
body->options->decompose_file_close_fn)
|
||||
body->options->decompose_file_close_fn(body->options->stream_closure);
|
||||
!mime_typep(body, (MimeObjectClass*)&mimeMultipartClass) &&
|
||||
body->options->decompose_file_close_fn)
|
||||
body->options->decompose_file_close_fn(body->options->stream_closure);
|
||||
#endif /* MIME_DRAFTS */
|
||||
|
||||
/* Put out a separator after every multipart/signed object. */
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
|
||||
#define MIME_SUPERCLASS mimeContainerClass
|
||||
MimeDefClass(MimeMultipart, MimeMultipartClass,
|
||||
mimeMultipartClass, &MIME_SUPERCLASS);
|
||||
mimeMultipartClass, &MIME_SUPERCLASS);
|
||||
|
||||
static int MimeMultipart_initialize (MimeObject *);
|
||||
static void MimeMultipart_finalize (MimeObject *);
|
||||
@@ -61,12 +61,12 @@ static int MimeMultipart_parse_line (const char *line, PRInt32 length, MimeObjec
|
||||
static int MimeMultipart_parse_eof (MimeObject *object, PRBool abort_p);
|
||||
|
||||
static MimeMultipartBoundaryType MimeMultipart_check_boundary(MimeObject *,
|
||||
const char *,
|
||||
PRInt32);
|
||||
const char *,
|
||||
PRInt32);
|
||||
static int MimeMultipart_create_child(MimeObject *);
|
||||
static PRBool MimeMultipart_output_child_p(MimeObject *, MimeObject *);
|
||||
static int MimeMultipart_parse_child_line (MimeObject *, const char *, PRInt32,
|
||||
PRBool);
|
||||
PRBool);
|
||||
static int MimeMultipart_close_child(MimeObject *);
|
||||
|
||||
extern "C" MimeObjectClass mimeMultipartAlternativeClass;
|
||||
@@ -116,8 +116,8 @@ MimeMultipart_initialize (MimeObject *object)
|
||||
|
||||
ct = MimeHeaders_get (object->headers, HEADER_CONTENT_TYPE, PR_FALSE, PR_FALSE);
|
||||
mult->boundary = (ct
|
||||
? MimeHeaders_get_parameter (ct, HEADER_PARM_BOUNDARY, NULL, NULL)
|
||||
: 0);
|
||||
? MimeHeaders_get_parameter (ct, HEADER_PARM_BOUNDARY, NULL, NULL)
|
||||
: 0);
|
||||
PR_FREEIF(ct);
|
||||
mult->state = MimeMultipartPreamble;
|
||||
return ((MimeObjectClass*)&MIME_SUPERCLASS)->initialize(object);
|
||||
@@ -133,14 +133,15 @@ MimeMultipart_finalize (MimeObject *object)
|
||||
|
||||
PR_FREEIF(mult->boundary);
|
||||
if (mult->hdrs)
|
||||
MimeHeaders_free(mult->hdrs);
|
||||
MimeHeaders_free(mult->hdrs);
|
||||
mult->hdrs = 0;
|
||||
((MimeObjectClass*)&MIME_SUPERCLASS)->finalize(object);
|
||||
}
|
||||
|
||||
int MimeWriteAString(MimeObject *obj, const nsACString &string)
|
||||
{
|
||||
return MimeObject_write(obj, nsCString(string).get(), string.Length(), PR_TRUE);
|
||||
const nsCString &flatString = PromiseFlatCString(string);
|
||||
return MimeObject_write(obj, flatString.get(), flatString.Length(), PR_TRUE);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -159,11 +160,11 @@ MimeMultipart_parse_line (const char *line, PRInt32 length, MimeObject *obj)
|
||||
/* If we're supposed to write this object, but aren't supposed to convert
|
||||
it to HTML, simply pass it through unaltered. */
|
||||
if (obj->output_p &&
|
||||
obj->options &&
|
||||
!obj->options->write_html_p &&
|
||||
obj->options->output_fn
|
||||
obj->options &&
|
||||
!obj->options->write_html_p &&
|
||||
obj->options->output_fn
|
||||
&& obj->options->format_out != nsMimeOutput::nsMimeMessageAttach)
|
||||
return MimeObject_write(obj, line, length, PR_TRUE);
|
||||
return MimeObject_write(obj, line, length, PR_TRUE);
|
||||
|
||||
|
||||
if (mult->state == MimeMultipartEpilogue) /* already done */
|
||||
@@ -234,8 +235,8 @@ MimeMultipart_parse_line (const char *line, PRInt32 length, MimeObject *obj)
|
||||
}
|
||||
|
||||
/* Otherwise, this isn't a boundary string. So do whatever it is we
|
||||
should do with this line (parse it as a header, feed it to the
|
||||
child part, ignore it, etc.) */
|
||||
should do with this line (parse it as a header, feed it to the
|
||||
child part, ignore it, etc.) */
|
||||
|
||||
switch (mult->state)
|
||||
{
|
||||
@@ -343,13 +344,13 @@ MimeMultipart_parse_line (const char *line, PRInt32 length, MimeObject *obj)
|
||||
PR_FALSE);
|
||||
if (!disposition)
|
||||
{
|
||||
if (!nsCRT::strcasecmp (firstChild->content_type, TEXT_PLAIN) ||
|
||||
!nsCRT::strcasecmp (firstChild->content_type, TEXT_HTML) ||
|
||||
!nsCRT::strcasecmp (firstChild->content_type, TEXT_MDL) ||
|
||||
!nsCRT::strcasecmp (firstChild->content_type, MULTIPART_ALTERNATIVE) ||
|
||||
!nsCRT::strcasecmp (firstChild->content_type, MULTIPART_RELATED) ||
|
||||
!nsCRT::strcasecmp (firstChild->content_type, MESSAGE_NEWS) ||
|
||||
!nsCRT::strcasecmp (firstChild->content_type, MESSAGE_RFC822))
|
||||
if (!PL_strcasecmp (firstChild->content_type, TEXT_PLAIN) ||
|
||||
!PL_strcasecmp (firstChild->content_type, TEXT_HTML) ||
|
||||
!PL_strcasecmp (firstChild->content_type, TEXT_MDL) ||
|
||||
!PL_strcasecmp (firstChild->content_type, MULTIPART_ALTERNATIVE) ||
|
||||
!PL_strcasecmp (firstChild->content_type, MULTIPART_RELATED) ||
|
||||
!PL_strcasecmp (firstChild->content_type, MESSAGE_NEWS) ||
|
||||
!PL_strcasecmp (firstChild->content_type, MESSAGE_RFC822))
|
||||
isBody = PR_TRUE;
|
||||
}
|
||||
}
|
||||
@@ -423,25 +424,25 @@ MimeMultipart_check_boundary(MimeObject *obj, const char *line, PRInt32 length)
|
||||
PRBool term_p;
|
||||
|
||||
if (!mult->boundary ||
|
||||
line[0] != '-' ||
|
||||
line[1] != '-')
|
||||
return MimeMultipartBoundaryTypeNone;
|
||||
line[0] != '-' ||
|
||||
line[1] != '-')
|
||||
return MimeMultipartBoundaryTypeNone;
|
||||
|
||||
/* This is a candidate line to be a boundary. Check it out... */
|
||||
blen = strlen(mult->boundary);
|
||||
term_p = PR_FALSE;
|
||||
|
||||
/* strip trailing whitespace (including the newline.) */
|
||||
while(length > 2 && nsCRT::IsAsciiSpace(line[length-1]))
|
||||
length--;
|
||||
while(length > 2 && IS_SPACE(line[length-1]))
|
||||
length--;
|
||||
|
||||
/* Could this be a terminating boundary? */
|
||||
if (length == blen + 4 &&
|
||||
line[length-1] == '-' &&
|
||||
line[length-2] == '-')
|
||||
{
|
||||
term_p = PR_TRUE;
|
||||
}
|
||||
line[length-1] == '-' &&
|
||||
line[length-2] == '-')
|
||||
{
|
||||
term_p = PR_TRUE;
|
||||
}
|
||||
|
||||
//looks like we have a separator but first, we need to check it's not for one of the part's children.
|
||||
MimeContainer *cont = (MimeContainer *) obj;
|
||||
@@ -477,41 +478,41 @@ MimeMultipart_create_child(MimeObject *obj)
|
||||
MimeMultipart *mult = (MimeMultipart *) obj;
|
||||
int status;
|
||||
char *ct = (mult->hdrs
|
||||
? MimeHeaders_get (mult->hdrs, HEADER_CONTENT_TYPE,
|
||||
PR_TRUE, PR_FALSE)
|
||||
: 0);
|
||||
? MimeHeaders_get (mult->hdrs, HEADER_CONTENT_TYPE,
|
||||
PR_TRUE, PR_FALSE)
|
||||
: 0);
|
||||
const char *dct = (((MimeMultipartClass *) obj->clazz)->default_part_type);
|
||||
MimeObject *body = NULL;
|
||||
|
||||
mult->state = MimeMultipartPartFirstLine;
|
||||
/* Don't pass in NULL as the content-type (this means that the
|
||||
auto-uudecode-hack won't ever be done for subparts of a
|
||||
multipart, but only for untyped children of message/rfc822.
|
||||
auto-uudecode-hack won't ever be done for subparts of a
|
||||
multipart, but only for untyped children of message/rfc822.
|
||||
*/
|
||||
body = mime_create(((ct && *ct) ? ct : (dct ? dct: TEXT_PLAIN)),
|
||||
mult->hdrs, obj->options);
|
||||
mult->hdrs, obj->options);
|
||||
PR_FREEIF(ct);
|
||||
if (!body) return MIME_OUT_OF_MEMORY;
|
||||
status = ((MimeContainerClass *) obj->clazz)->add_child(obj, body);
|
||||
if (status < 0)
|
||||
{
|
||||
mime_free(body);
|
||||
return status;
|
||||
}
|
||||
{
|
||||
mime_free(body);
|
||||
return status;
|
||||
}
|
||||
|
||||
#ifdef MIME_DRAFTS
|
||||
if ( obj->options &&
|
||||
obj->options->decompose_file_p &&
|
||||
obj->options->is_multipart_msg &&
|
||||
obj->options->decompose_file_init_fn )
|
||||
{
|
||||
if ( !mime_typep(obj,(MimeObjectClass*)&mimeMultipartRelatedClass) &&
|
||||
obj->options->decompose_file_p &&
|
||||
obj->options->is_multipart_msg &&
|
||||
obj->options->decompose_file_init_fn )
|
||||
{
|
||||
if ( !mime_typep(obj,(MimeObjectClass*)&mimeMultipartRelatedClass) &&
|
||||
!mime_typep(obj,(MimeObjectClass*)&mimeMultipartAlternativeClass) &&
|
||||
!mime_typep(obj,(MimeObjectClass*)&mimeMultipartSignedClass) &&
|
||||
!mime_typep(obj,(MimeObjectClass*)&mimeMultipartSignedClass) &&
|
||||
#ifdef MIME_DETAIL_CHECK
|
||||
!mime_typep(body, (MimeObjectClass*)&mimeMultipartRelatedClass) &&
|
||||
!mime_typep(body, (MimeObjectClass*)&mimeMultipartAlternativeClass) &&
|
||||
!mime_typep(body,(MimeObjectClass*)&mimeMultipartSignedClass)
|
||||
!mime_typep(body, (MimeObjectClass*)&mimeMultipartRelatedClass) &&
|
||||
!mime_typep(body, (MimeObjectClass*)&mimeMultipartAlternativeClass) &&
|
||||
!mime_typep(body,(MimeObjectClass*)&mimeMultipartSignedClass)
|
||||
#else
|
||||
/* bug 21869 -- due to the fact that we are not generating the
|
||||
correct mime class object for content-typ multipart/signed part
|
||||
@@ -524,37 +525,37 @@ MimeMultipart_create_child(MimeObject *obj)
|
||||
#endif
|
||||
&& ! (mime_typep(body, (MimeObjectClass*)&mimeExternalObjectClass) && !strcmp(body->content_type, "text/x-vcard"))
|
||||
)
|
||||
{
|
||||
status = obj->options->decompose_file_init_fn ( obj->options->stream_closure, mult->hdrs );
|
||||
if (status < 0) return status;
|
||||
}
|
||||
}
|
||||
{
|
||||
status = obj->options->decompose_file_init_fn ( obj->options->stream_closure, mult->hdrs );
|
||||
if (status < 0) return status;
|
||||
}
|
||||
}
|
||||
#endif /* MIME_DRAFTS */
|
||||
|
||||
|
||||
/* Now that we've added this new object to our list of children,
|
||||
start its parser going (if we want to display it.)
|
||||
start its parser going (if we want to display it.)
|
||||
*/
|
||||
body->output_p = (((MimeMultipartClass *) obj->clazz)->output_child_p(obj, body));
|
||||
if (body->output_p)
|
||||
{
|
||||
status = body->clazz->parse_begin(body);
|
||||
{
|
||||
status = body->clazz->parse_begin(body);
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
/* if we are saving an apple double attachment, we need to set correctly the conten type of the channel */
|
||||
if (mime_typep(obj, (MimeObjectClass *) &mimeMultipartAppleDoubleClass))
|
||||
{
|
||||
struct mime_stream_data *msd = (struct mime_stream_data *)body->options->stream_closure;
|
||||
if (!body->options->write_html_p && body->content_type && !nsCRT::strcasecmp(body->content_type, APPLICATION_APPLEFILE))
|
||||
if (!body->options->write_html_p && body->content_type && !PL_strcasecmp(body->content_type, APPLICATION_APPLEFILE))
|
||||
{
|
||||
if (msd && msd->channel)
|
||||
msd->channel->SetContentType(NS_LITERAL_CSTRING(APPLICATION_APPLEFILE));
|
||||
if (msd && msd->channel)
|
||||
msd->channel->SetContentType(NS_LITERAL_CSTRING(APPLICATION_APPLEFILE));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (status < 0) return status;
|
||||
}
|
||||
if (status < 0) return status;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -564,7 +565,7 @@ static PRBool
|
||||
MimeMultipart_output_child_p(MimeObject *obj, MimeObject *child)
|
||||
{
|
||||
/* if we are saving an apple double attachment, ignore the appledouble wrapper part */
|
||||
return obj->options->write_html_p || nsCRT::strcasecmp(child->content_type, MULTIPART_APPLEDOUBLE);
|
||||
return obj->options->write_html_p || PL_strcasecmp(child->content_type, MULTIPART_APPLEDOUBLE);
|
||||
}
|
||||
|
||||
|
||||
@@ -576,36 +577,36 @@ MimeMultipart_close_child(MimeObject *object)
|
||||
MimeContainer *cont = (MimeContainer *) object;
|
||||
|
||||
if (!mult->hdrs)
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
MimeHeaders_free(mult->hdrs);
|
||||
mult->hdrs = 0;
|
||||
|
||||
NS_ASSERTION(cont->nchildren > 0, "badly formed mime message");
|
||||
if (cont->nchildren > 0)
|
||||
{
|
||||
MimeObject *kid = cont->children[cont->nchildren-1];
|
||||
if (kid)
|
||||
{
|
||||
int status;
|
||||
status = kid->clazz->parse_eof(kid, PR_FALSE);
|
||||
if (status < 0) return status;
|
||||
status = kid->clazz->parse_end(kid, PR_FALSE);
|
||||
if (status < 0) return status;
|
||||
{
|
||||
MimeObject *kid = cont->children[cont->nchildren-1];
|
||||
if (kid)
|
||||
{
|
||||
int status;
|
||||
status = kid->clazz->parse_eof(kid, PR_FALSE);
|
||||
if (status < 0) return status;
|
||||
status = kid->clazz->parse_end(kid, PR_FALSE);
|
||||
if (status < 0) return status;
|
||||
|
||||
#ifdef MIME_DRAFTS
|
||||
if ( object->options &&
|
||||
object->options->decompose_file_p &&
|
||||
object->options->is_multipart_msg &&
|
||||
object->options->decompose_file_close_fn )
|
||||
{
|
||||
if ( !mime_typep(object,(MimeObjectClass*)&mimeMultipartRelatedClass) &&
|
||||
!mime_typep(object,(MimeObjectClass*)&mimeMultipartAlternativeClass) &&
|
||||
!mime_typep(object,(MimeObjectClass*)&mimeMultipartSignedClass) &&
|
||||
if ( object->options &&
|
||||
object->options->decompose_file_p &&
|
||||
object->options->is_multipart_msg &&
|
||||
object->options->decompose_file_close_fn )
|
||||
{
|
||||
if ( !mime_typep(object,(MimeObjectClass*)&mimeMultipartRelatedClass) &&
|
||||
!mime_typep(object,(MimeObjectClass*)&mimeMultipartAlternativeClass) &&
|
||||
!mime_typep(object,(MimeObjectClass*)&mimeMultipartSignedClass) &&
|
||||
#ifdef MIME_DETAIL_CHECK
|
||||
!mime_typep(kid,(MimeObjectClass*)&mimeMultipartRelatedClass) &&
|
||||
!mime_typep(kid,(MimeObjectClass*)&mimeMultipartAlternativeClass) &&
|
||||
!mime_typep(kid,(MimeObjectClass*)&mimeMultipartSignedClass)
|
||||
!mime_typep(kid,(MimeObjectClass*)&mimeMultipartRelatedClass) &&
|
||||
!mime_typep(kid,(MimeObjectClass*)&mimeMultipartAlternativeClass) &&
|
||||
!mime_typep(kid,(MimeObjectClass*)&mimeMultipartSignedClass)
|
||||
#else
|
||||
/* bug 21869 -- due to the fact that we are not generating the
|
||||
correct mime class object for content-typ multipart/signed part
|
||||
@@ -618,22 +619,22 @@ MimeMultipart_close_child(MimeObject *object)
|
||||
#endif
|
||||
&& !(mime_typep(kid, (MimeObjectClass*)&mimeExternalObjectClass) && !strcmp(kid->content_type, "text/x-vcard"))
|
||||
)
|
||||
{
|
||||
status = object->options->decompose_file_close_fn ( object->options->stream_closure );
|
||||
if (status < 0) return status;
|
||||
}
|
||||
}
|
||||
{
|
||||
status = object->options->decompose_file_close_fn ( object->options->stream_closure );
|
||||
if (status < 0) return status;
|
||||
}
|
||||
}
|
||||
#endif /* MIME_DRAFTS */
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
MimeMultipart_parse_child_line (MimeObject *obj, const char *line, PRInt32 length,
|
||||
PRBool first_line_p)
|
||||
PRBool first_line_p)
|
||||
{
|
||||
MimeContainer *cont = (MimeContainer *) obj;
|
||||
int status;
|
||||
@@ -641,7 +642,7 @@ MimeMultipart_parse_child_line (MimeObject *obj, const char *line, PRInt32 lengt
|
||||
|
||||
PR_ASSERT(cont->nchildren > 0);
|
||||
if (cont->nchildren <= 0)
|
||||
return -1;
|
||||
return -1;
|
||||
|
||||
kid = cont->children[cont->nchildren-1];
|
||||
PR_ASSERT(kid);
|
||||
@@ -649,17 +650,17 @@ MimeMultipart_parse_child_line (MimeObject *obj, const char *line, PRInt32 lengt
|
||||
|
||||
#ifdef MIME_DRAFTS
|
||||
if ( obj->options &&
|
||||
obj->options->decompose_file_p &&
|
||||
obj->options->is_multipart_msg &&
|
||||
obj->options->decompose_file_output_fn )
|
||||
obj->options->decompose_file_p &&
|
||||
obj->options->is_multipart_msg &&
|
||||
obj->options->decompose_file_output_fn )
|
||||
{
|
||||
if (!mime_typep(obj,(MimeObjectClass*)&mimeMultipartAlternativeClass) &&
|
||||
!mime_typep(obj,(MimeObjectClass*)&mimeMultipartRelatedClass) &&
|
||||
!mime_typep(obj,(MimeObjectClass*)&mimeMultipartSignedClass) &&
|
||||
if (!mime_typep(obj,(MimeObjectClass*)&mimeMultipartAlternativeClass) &&
|
||||
!mime_typep(obj,(MimeObjectClass*)&mimeMultipartRelatedClass) &&
|
||||
!mime_typep(obj,(MimeObjectClass*)&mimeMultipartSignedClass) &&
|
||||
#ifdef MIME_DETAIL_CHECK
|
||||
!mime_typep(kid,(MimeObjectClass*)&mimeMultipartAlternativeClass) &&
|
||||
!mime_typep(kid,(MimeObjectClass*)&mimeMultipartRelatedClass) &&
|
||||
!mime_typep(kid,(MimeObjectClass*)&mimeMultipartSignedClass)
|
||||
!mime_typep(kid,(MimeObjectClass*)&mimeMultipartAlternativeClass) &&
|
||||
!mime_typep(kid,(MimeObjectClass*)&mimeMultipartRelatedClass) &&
|
||||
!mime_typep(kid,(MimeObjectClass*)&mimeMultipartSignedClass)
|
||||
#else
|
||||
/* bug 21869 -- due to the fact that we are not generating the
|
||||
correct mime class object for content-typ multipart/signed part
|
||||
@@ -672,18 +673,18 @@ MimeMultipart_parse_child_line (MimeObject *obj, const char *line, PRInt32 lengt
|
||||
#endif
|
||||
&& !(mime_typep(kid, (MimeObjectClass*)&mimeExternalObjectClass) && !strcmp(kid->content_type, "text/x-vcard"))
|
||||
)
|
||||
return obj->options->decompose_file_output_fn (line, length, obj->options->stream_closure);
|
||||
return obj->options->decompose_file_output_fn (line, length, obj->options->stream_closure);
|
||||
}
|
||||
#endif /* MIME_DRAFTS */
|
||||
|
||||
/* The newline issues here are tricky, since both the newlines before
|
||||
and after the boundary string are to be considered part of the
|
||||
boundary: this is so that a part can be specified such that it
|
||||
does not end in a trailing newline.
|
||||
and after the boundary string are to be considered part of the
|
||||
boundary: this is so that a part can be specified such that it
|
||||
does not end in a trailing newline.
|
||||
|
||||
To implement this, we send a newline *before* each line instead
|
||||
of after, except for the first line, which is not preceeded by a
|
||||
newline.
|
||||
To implement this, we send a newline *before* each line instead
|
||||
of after, except for the first line, which is not preceeded by a
|
||||
newline.
|
||||
*/
|
||||
|
||||
/* Remove the trailing newline... */
|
||||
@@ -691,12 +692,12 @@ MimeMultipart_parse_child_line (MimeObject *obj, const char *line, PRInt32 lengt
|
||||
if (length > 0 && line[length-1] == '\r') length--;
|
||||
|
||||
if (!first_line_p)
|
||||
{
|
||||
/* Push out a preceeding newline... */
|
||||
char nl[] = MSG_LINEBREAK;
|
||||
status = kid->clazz->parse_buffer (nl, MSG_LINEBREAK_LEN, kid);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
{
|
||||
/* Push out a preceeding newline... */
|
||||
char nl[] = MSG_LINEBREAK;
|
||||
status = kid->clazz->parse_buffer (nl, MSG_LINEBREAK_LEN, kid);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
|
||||
/* Now push out the line sans trailing newline. */
|
||||
return kid->clazz->parse_buffer (line, length, kid);
|
||||
@@ -712,36 +713,36 @@ MimeMultipart_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
if (obj->closed_p) return 0;
|
||||
|
||||
/* Push out one last newline if part of the last line is still in the
|
||||
ibuffer. If this happens, this object does not end in a trailing newline
|
||||
(and the parse_line method will be called with a string with no trailing
|
||||
newline, which isn't the usual case.)
|
||||
ibuffer. If this happens, this object does not end in a trailing newline
|
||||
(and the parse_line method will be called with a string with no trailing
|
||||
newline, which isn't the usual case.)
|
||||
*/
|
||||
if (!abort_p && obj->ibuffer_fp > 0)
|
||||
{
|
||||
int status = obj->clazz->parse_buffer (obj->ibuffer, obj->ibuffer_fp,
|
||||
obj);
|
||||
obj->ibuffer_fp = 0;
|
||||
if (status < 0)
|
||||
{
|
||||
obj->closed_p = PR_TRUE;
|
||||
return status;
|
||||
}
|
||||
}
|
||||
{
|
||||
int status = obj->clazz->parse_buffer (obj->ibuffer, obj->ibuffer_fp,
|
||||
obj);
|
||||
obj->ibuffer_fp = 0;
|
||||
if (status < 0)
|
||||
{
|
||||
obj->closed_p = PR_TRUE;
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
/* Now call parse_eof for our active child, if there is one.
|
||||
*/
|
||||
if (cont->nchildren > 0 &&
|
||||
(mult->state == MimeMultipartPartLine ||
|
||||
mult->state == MimeMultipartPartFirstLine))
|
||||
{
|
||||
MimeObject *kid = cont->children[cont->nchildren-1];
|
||||
PR_ASSERT(kid);
|
||||
if (kid)
|
||||
{
|
||||
int status = kid->clazz->parse_eof(kid, abort_p);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
}
|
||||
(mult->state == MimeMultipartPartLine ||
|
||||
mult->state == MimeMultipartPartFirstLine))
|
||||
{
|
||||
MimeObject *kid = cont->children[cont->nchildren-1];
|
||||
PR_ASSERT(kid);
|
||||
if (kid)
|
||||
{
|
||||
int status = kid->clazz->parse_eof(kid, abort_p);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
}
|
||||
|
||||
return ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_eof(obj, abort_p);
|
||||
}
|
||||
@@ -756,32 +757,32 @@ MimeMultipart_debug_print (MimeObject *obj, PRFileDesc *stream, PRInt32 depth)
|
||||
char *addr = mime_part_address(obj);
|
||||
int i;
|
||||
for (i=0; i < depth; i++)
|
||||
PR_Write(stream, " ", 2);
|
||||
PR_Write(stream, " ", 2);
|
||||
/**
|
||||
fprintf(stream, "<%s %s (%d kid%s) boundary=%s 0x%08X>\n",
|
||||
obj->clazz->class_name,
|
||||
addr ? addr : "???",
|
||||
cont->nchildren, (cont->nchildren == 1 ? "" : "s"),
|
||||
(mult->boundary ? mult->boundary : "(none)"),
|
||||
(PRUint32) mult);
|
||||
obj->clazz->class_name,
|
||||
addr ? addr : "???",
|
||||
cont->nchildren, (cont->nchildren == 1 ? "" : "s"),
|
||||
(mult->boundary ? mult->boundary : "(none)"),
|
||||
(PRUint32) mult);
|
||||
**/
|
||||
PR_FREEIF(addr);
|
||||
|
||||
/*
|
||||
if (cont->nchildren > 0)
|
||||
fprintf(stream, "\n");
|
||||
fprintf(stream, "\n");
|
||||
*/
|
||||
|
||||
for (i = 0; i < cont->nchildren; i++)
|
||||
{
|
||||
MimeObject *kid = cont->children[i];
|
||||
int status = kid->clazz->debug_print (kid, stream, depth+1);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
{
|
||||
MimeObject *kid = cont->children[i];
|
||||
int status = kid->clazz->debug_print (kid, stream, depth+1);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
|
||||
/*
|
||||
if (cont->nchildren > 0)
|
||||
fprintf(stream, "\n");
|
||||
fprintf(stream, "\n");
|
||||
*/
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK *****
|
||||
* This Original Code has been modified by IBM Corporation. Modifications made by IBM
|
||||
* This Original Code has been modified by IBM Corporation. Modifications made by IBM
|
||||
* described herein are Copyright (c) International Business Machines Corporation, 2000.
|
||||
* Modifications to Mozilla code or documentation identified per MPL Section 3.3
|
||||
*
|
||||
@@ -50,7 +50,6 @@
|
||||
#include "mimebuf.h"
|
||||
#include "prlog.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsMimeStringResources.h"
|
||||
#include "mimemsg.h"
|
||||
#include "mimemapl.h"
|
||||
@@ -70,7 +69,7 @@ static int MimeObject_parse_line (const char *, PRInt32, MimeObject *);
|
||||
static int MimeObject_parse_eof (MimeObject *, PRBool);
|
||||
static int MimeObject_parse_end (MimeObject *, PRBool);
|
||||
static PRBool MimeObject_displayable_inline_p (MimeObjectClass *clazz,
|
||||
MimeHeaders *hdrs);
|
||||
MimeHeaders *hdrs);
|
||||
|
||||
#if defined(DEBUG) && defined(XP_UNIX)
|
||||
static int MimeObject_debug_print (MimeObject *, PRFileDesc *, PRInt32 depth);
|
||||
@@ -104,55 +103,55 @@ MimeObject_initialize (MimeObject *obj)
|
||||
|
||||
/* Set up the content-type and encoding. */
|
||||
if (!obj->content_type && obj->headers)
|
||||
obj->content_type = MimeHeaders_get (obj->headers, HEADER_CONTENT_TYPE,
|
||||
PR_TRUE, PR_FALSE);
|
||||
obj->content_type = MimeHeaders_get (obj->headers, HEADER_CONTENT_TYPE,
|
||||
PR_TRUE, PR_FALSE);
|
||||
if (!obj->encoding && obj->headers)
|
||||
obj->encoding = MimeHeaders_get (obj->headers,
|
||||
HEADER_CONTENT_TRANSFER_ENCODING,
|
||||
PR_TRUE, PR_FALSE);
|
||||
obj->encoding = MimeHeaders_get (obj->headers,
|
||||
HEADER_CONTENT_TRANSFER_ENCODING,
|
||||
PR_TRUE, PR_FALSE);
|
||||
|
||||
|
||||
/* Special case to normalize some types and encodings to a canonical form.
|
||||
(These are nonstandard types/encodings which have been seen to appear in
|
||||
multiple forms; we normalize them so that things like looking up icons
|
||||
and extensions has consistent behavior for the receiver, regardless of
|
||||
the "alias" type that the sender used.)
|
||||
(These are nonstandard types/encodings which have been seen to appear in
|
||||
multiple forms; we normalize them so that things like looking up icons
|
||||
and extensions has consistent behavior for the receiver, regardless of
|
||||
the "alias" type that the sender used.)
|
||||
*/
|
||||
if (!obj->content_type)
|
||||
;
|
||||
else if (!nsCRT::strcasecmp(obj->content_type, APPLICATION_UUENCODE2) ||
|
||||
!nsCRT::strcasecmp(obj->content_type, APPLICATION_UUENCODE3) ||
|
||||
!nsCRT::strcasecmp(obj->content_type, APPLICATION_UUENCODE4))
|
||||
{
|
||||
PR_Free(obj->content_type);
|
||||
obj->content_type = nsCRT::strdup(APPLICATION_UUENCODE);
|
||||
}
|
||||
else if (!nsCRT::strcasecmp(obj->content_type, IMAGE_XBM2) ||
|
||||
!nsCRT::strcasecmp(obj->content_type, IMAGE_XBM3))
|
||||
{
|
||||
PR_Free(obj->content_type);
|
||||
obj->content_type = nsCRT::strdup(IMAGE_XBM);
|
||||
}
|
||||
;
|
||||
else if (!PL_strcasecmp(obj->content_type, APPLICATION_UUENCODE2) ||
|
||||
!PL_strcasecmp(obj->content_type, APPLICATION_UUENCODE3) ||
|
||||
!PL_strcasecmp(obj->content_type, APPLICATION_UUENCODE4))
|
||||
{
|
||||
PR_Free(obj->content_type);
|
||||
obj->content_type = strdup(APPLICATION_UUENCODE);
|
||||
}
|
||||
else if (!PL_strcasecmp(obj->content_type, IMAGE_XBM2) ||
|
||||
!PL_strcasecmp(obj->content_type, IMAGE_XBM3))
|
||||
{
|
||||
PR_Free(obj->content_type);
|
||||
obj->content_type = strdup(IMAGE_XBM);
|
||||
}
|
||||
|
||||
if (!obj->encoding)
|
||||
;
|
||||
else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE2) ||
|
||||
!nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE3) ||
|
||||
!nsCRT::strcasecmp(obj->encoding, ENCODING_UUENCODE4))
|
||||
{
|
||||
PR_Free(obj->encoding);
|
||||
obj->encoding = nsCRT::strdup(ENCODING_UUENCODE);
|
||||
}
|
||||
else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_COMPRESS2))
|
||||
{
|
||||
PR_Free(obj->encoding);
|
||||
obj->encoding = nsCRT::strdup(ENCODING_COMPRESS);
|
||||
}
|
||||
else if (!nsCRT::strcasecmp(obj->encoding, ENCODING_GZIP2))
|
||||
{
|
||||
PR_Free(obj->encoding);
|
||||
obj->encoding = nsCRT::strdup(ENCODING_GZIP);
|
||||
}
|
||||
;
|
||||
else if (!PL_strcasecmp(obj->encoding, ENCODING_UUENCODE2) ||
|
||||
!PL_strcasecmp(obj->encoding, ENCODING_UUENCODE3) ||
|
||||
!PL_strcasecmp(obj->encoding, ENCODING_UUENCODE4))
|
||||
{
|
||||
PR_Free(obj->encoding);
|
||||
obj->encoding = strdup(ENCODING_UUENCODE);
|
||||
}
|
||||
else if (!PL_strcasecmp(obj->encoding, ENCODING_COMPRESS2))
|
||||
{
|
||||
PR_Free(obj->encoding);
|
||||
obj->encoding = strdup(ENCODING_COMPRESS);
|
||||
}
|
||||
else if (!PL_strcasecmp(obj->encoding, ENCODING_GZIP2))
|
||||
{
|
||||
PR_Free(obj->encoding);
|
||||
obj->encoding = strdup(ENCODING_GZIP);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
@@ -165,10 +164,10 @@ MimeObject_finalize (MimeObject *obj)
|
||||
obj->clazz->parse_end (obj, PR_FALSE);
|
||||
|
||||
if (obj->headers)
|
||||
{
|
||||
MimeHeaders_free(obj->headers);
|
||||
obj->headers = 0;
|
||||
}
|
||||
{
|
||||
MimeHeaders_free(obj->headers);
|
||||
obj->headers = 0;
|
||||
}
|
||||
|
||||
/* Should have been freed by parse_eof, but just in case... */
|
||||
NS_ASSERTION(!obj->ibuffer, "buffer not freed");
|
||||
@@ -180,10 +179,10 @@ MimeObject_finalize (MimeObject *obj)
|
||||
PR_FREEIF(obj->encoding);
|
||||
|
||||
if (obj->options && obj->options->state)
|
||||
{
|
||||
delete obj->options->state;
|
||||
obj->options->state = nsnull;
|
||||
}
|
||||
{
|
||||
delete obj->options->state;
|
||||
obj->options->state = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -193,7 +192,7 @@ MimeObject_parse_begin (MimeObject *obj)
|
||||
NS_ASSERTION (!obj->closed_p, "object shouldn't be already closed");
|
||||
|
||||
/* If we haven't set up the state object yet, then this should be
|
||||
the outermost object... */
|
||||
the outermost object... */
|
||||
if (obj->options && !obj->options->state)
|
||||
{
|
||||
NS_ASSERTION(!obj->headers, "headers should be null"); /* should be the outermost object. */
|
||||
@@ -209,7 +208,7 @@ MimeObject_parse_begin (MimeObject *obj)
|
||||
const char *delEnd = PL_strcasestr(delParts + 1, "&");
|
||||
if (!delEnd)
|
||||
delEnd = delParts + strlen(delParts);
|
||||
nsCAutoString partsToDel(Substring(delParts + 5, delEnd));
|
||||
nsCAutoString partsToDel(Substring(delParts + 5, delEnd));
|
||||
obj->options->state->partsToStrip.ParseString(partsToDel.get(), ",");
|
||||
}
|
||||
if (detachLocations)
|
||||
@@ -224,23 +223,23 @@ MimeObject_parse_begin (MimeObject *obj)
|
||||
/* if we are decomposing the message in files and processing a multipart object,
|
||||
we must not output it without parsing it first */
|
||||
|| (obj->options->decompose_file_p && obj->options->decompose_file_output_fn &&
|
||||
mime_typep(obj, (MimeObjectClass*) &mimeMultipartClass))
|
||||
mime_typep(obj, (MimeObjectClass*) &mimeMultipartClass))
|
||||
)
|
||||
obj->output_p = PR_FALSE;
|
||||
obj->output_p = PR_FALSE;
|
||||
else if (!obj->options->part_to_load)
|
||||
obj->output_p = PR_TRUE;
|
||||
obj->output_p = PR_TRUE;
|
||||
else
|
||||
{
|
||||
char *id = mime_part_address(obj);
|
||||
if (!id) return MIME_OUT_OF_MEMORY;
|
||||
{
|
||||
char *id = mime_part_address(obj);
|
||||
if (!id) return MIME_OUT_OF_MEMORY;
|
||||
|
||||
// We need to check if a part is the subpart of the part to load.
|
||||
// If so and this is a raw or body display output operation, then
|
||||
// we should mark the part for subsequent output.
|
||||
//
|
||||
|
||||
|
||||
// First, check for an exact match
|
||||
obj->output_p = !strcmp(id, obj->options->part_to_load);
|
||||
obj->output_p = !strcmp(id, obj->options->part_to_load);
|
||||
if (!obj->output_p && (obj->options->format_out == nsMimeOutput::nsMimeMessageRaw ||
|
||||
obj->options->format_out == nsMimeOutput::nsMimeMessageBodyDisplay
|
||||
|| obj->options->format_out == nsMimeOutput::nsMimeMessageAttach))
|
||||
@@ -251,19 +250,19 @@ MimeObject_parse_begin (MimeObject *obj)
|
||||
!strncmp(id, obj->options->part_to_load, partlen);
|
||||
}
|
||||
|
||||
PR_Free(id);
|
||||
}
|
||||
PR_Free(id);
|
||||
}
|
||||
|
||||
/* Way to destroy any notions of modularity or class hierarchy, Terry! */
|
||||
if (obj->options && obj->options->nice_html_only_p) {
|
||||
if (!mime_subclass_p(obj->clazz,
|
||||
(MimeObjectClass*) &mimeInlineTextHTMLClass) &&
|
||||
!mime_subclass_p(obj->clazz,
|
||||
(MimeObjectClass*) &mimeInlineTextPlainClass) &&
|
||||
!mime_subclass_p(obj->clazz,
|
||||
(MimeObjectClass*) &mimeContainerClass)) {
|
||||
obj->output_p = PR_FALSE;
|
||||
}
|
||||
if (!mime_subclass_p(obj->clazz,
|
||||
(MimeObjectClass*) &mimeInlineTextHTMLClass) &&
|
||||
!mime_subclass_p(obj->clazz,
|
||||
(MimeObjectClass*) &mimeInlineTextPlainClass) &&
|
||||
!mime_subclass_p(obj->clazz,
|
||||
(MimeObjectClass*) &mimeContainerClass)) {
|
||||
obj->output_p = PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -276,12 +275,12 @@ MimeObject_parse_buffer (const char *buffer, PRInt32 size, MimeObject *obj)
|
||||
if (obj->closed_p) return -1;
|
||||
|
||||
return mime_LineBuffer (buffer, size,
|
||||
&obj->ibuffer, &obj->ibuffer_size, &obj->ibuffer_fp,
|
||||
PR_TRUE,
|
||||
((int (*PR_CALLBACK) (char *, PRInt32, void *))
|
||||
/* This cast is to turn void into MimeObject */
|
||||
obj->clazz->parse_line),
|
||||
obj);
|
||||
&obj->ibuffer, &obj->ibuffer_size, &obj->ibuffer_fp,
|
||||
PR_TRUE,
|
||||
((int (*PR_CALLBACK) (char *, PRInt32, void *))
|
||||
/* This cast is to turn void into MimeObject */
|
||||
obj->clazz->parse_line),
|
||||
obj);
|
||||
}
|
||||
|
||||
|
||||
@@ -300,21 +299,21 @@ MimeObject_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
NS_ASSERTION(!obj->parsed_p, "obj already parsed");
|
||||
|
||||
/* If there is still data in the ibuffer, that means that the last line of
|
||||
this part didn't end in a newline; so push it out anyway (this means that
|
||||
the parse_line method will be called with a string with no trailing
|
||||
newline, which isn't the usual case.)
|
||||
this part didn't end in a newline; so push it out anyway (this means that
|
||||
the parse_line method will be called with a string with no trailing
|
||||
newline, which isn't the usual case.)
|
||||
*/
|
||||
if (!abort_p &&
|
||||
obj->ibuffer_fp > 0)
|
||||
{
|
||||
int status = obj->clazz->parse_line (obj->ibuffer, obj->ibuffer_fp, obj);
|
||||
obj->ibuffer_fp = 0;
|
||||
if (status < 0)
|
||||
{
|
||||
obj->closed_p = PR_TRUE;
|
||||
return status;
|
||||
}
|
||||
}
|
||||
obj->ibuffer_fp > 0)
|
||||
{
|
||||
int status = obj->clazz->parse_line (obj->ibuffer, obj->ibuffer_fp, obj);
|
||||
obj->ibuffer_fp = 0;
|
||||
if (status < 0)
|
||||
{
|
||||
obj->closed_p = PR_TRUE;
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
obj->closed_p = PR_TRUE;
|
||||
return 0;
|
||||
@@ -325,10 +324,10 @@ static int
|
||||
MimeObject_parse_end (MimeObject *obj, PRBool abort_p)
|
||||
{
|
||||
if (obj->parsed_p)
|
||||
{
|
||||
NS_ASSERTION(obj->closed_p, "object should be closed");
|
||||
return 0;
|
||||
}
|
||||
{
|
||||
NS_ASSERTION(obj->closed_p, "object should be closed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* We won't be needing these buffers any more; nuke 'em. */
|
||||
PR_FREEIF(obj->ibuffer);
|
||||
@@ -359,11 +358,11 @@ MimeObject_debug_print (MimeObject *obj, PRFileDesc *stream, PRInt32 depth)
|
||||
int i;
|
||||
char *addr = mime_part_address(obj);
|
||||
for (i=0; i < depth; i++)
|
||||
PR_Write(stream, " ", 2);
|
||||
PR_Write(stream, " ", 2);
|
||||
/*
|
||||
fprintf(stream, "<%s %s 0x%08X>\n", obj->clazz->class_name,
|
||||
addr ? addr : "???",
|
||||
(PRUint32) obj);
|
||||
addr ? addr : "???",
|
||||
(PRUint32) obj);
|
||||
*/
|
||||
PR_FREEIF(addr);
|
||||
return 0;
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
#include "prmem.h"
|
||||
#include "prio.h"
|
||||
#include "plstr.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsMimeStringResources.h"
|
||||
#include "nsNetUtil.h"
|
||||
//
|
||||
|
||||
@@ -45,14 +45,14 @@
|
||||
|
||||
#define MIME_SUPERCLASS mimeMultipartClass
|
||||
MimeDefClass(MimeSunAttachment, MimeSunAttachmentClass,
|
||||
mimeSunAttachmentClass, &MIME_SUPERCLASS);
|
||||
mimeSunAttachmentClass, &MIME_SUPERCLASS);
|
||||
|
||||
static MimeMultipartBoundaryType MimeSunAttachment_check_boundary(MimeObject *,
|
||||
const char *,
|
||||
PRInt32);
|
||||
const char *,
|
||||
PRInt32);
|
||||
static int MimeSunAttachment_create_child(MimeObject *);
|
||||
static int MimeSunAttachment_parse_child_line (MimeObject *, const char *, PRInt32,
|
||||
PRBool);
|
||||
PRBool);
|
||||
static int MimeSunAttachment_parse_begin (MimeObject *);
|
||||
static int MimeSunAttachment_parse_eof (MimeObject *, PRBool);
|
||||
|
||||
@@ -92,10 +92,10 @@ MimeSunAttachment_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
|
||||
/* Sun messages always have separators at the end. */
|
||||
if (!abort_p)
|
||||
{
|
||||
status = MimeObject_write_separator(obj);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
{
|
||||
status = MimeObject_write_separator(obj);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -103,18 +103,18 @@ MimeSunAttachment_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
|
||||
static MimeMultipartBoundaryType
|
||||
MimeSunAttachment_check_boundary(MimeObject *obj, const char *line,
|
||||
PRInt32 length)
|
||||
PRInt32 length)
|
||||
{
|
||||
/* ten dashes */
|
||||
|
||||
if (line &&
|
||||
line[0] == '-' && line[1] == '-' && line[2] == '-' && line[3] == '-' &&
|
||||
line[4] == '-' && line[5] == '-' && line[6] == '-' && line[7] == '-' &&
|
||||
line[8] == '-' && line[9] == '-' &&
|
||||
(line[10] == '\r' || line[10] == '\n'))
|
||||
return MimeMultipartBoundaryTypeSeparator;
|
||||
line[0] == '-' && line[1] == '-' && line[2] == '-' && line[3] == '-' &&
|
||||
line[4] == '-' && line[5] == '-' && line[6] == '-' && line[7] == '-' &&
|
||||
line[8] == '-' && line[9] == '-' &&
|
||||
(line[10] == '\r' || line[10] == '\n'))
|
||||
return MimeMultipartBoundaryTypeSeparator;
|
||||
else
|
||||
return MimeMultipartBoundaryTypeNone;
|
||||
return MimeMultipartBoundaryTypeNone;
|
||||
}
|
||||
|
||||
|
||||
@@ -132,104 +132,104 @@ MimeSunAttachment_create_child(MimeObject *obj)
|
||||
mult->state = MimeMultipartPartLine;
|
||||
|
||||
sun_data_type = (mult->hdrs
|
||||
? MimeHeaders_get (mult->hdrs, HEADER_X_SUN_DATA_TYPE,
|
||||
PR_TRUE, PR_FALSE)
|
||||
: 0);
|
||||
? MimeHeaders_get (mult->hdrs, HEADER_X_SUN_DATA_TYPE,
|
||||
PR_TRUE, PR_FALSE)
|
||||
: 0);
|
||||
if (sun_data_type)
|
||||
{
|
||||
int i;
|
||||
static const struct { const char *in, *out; } sun_types[] = {
|
||||
{
|
||||
int i;
|
||||
static const struct { const char *in, *out; } sun_types[] = {
|
||||
|
||||
/* Convert recognised Sun types to the corresponding MIME types,
|
||||
and convert unrecognized ones based on the file extension and
|
||||
the mime.types file.
|
||||
/* Convert recognised Sun types to the corresponding MIME types,
|
||||
and convert unrecognized ones based on the file extension and
|
||||
the mime.types file.
|
||||
|
||||
These are the magic types used by MailTool that I can determine.
|
||||
The only actual written spec I've found only listed the first few.
|
||||
The rest were found by inspection (both of real-world messages,
|
||||
and by running `strings' on the MailTool binary, and on the file
|
||||
/usr/openwin/lib/cetables/cetables (the "Class Engine", Sun's
|
||||
equivalent to .mailcap and mime.types.)
|
||||
*/
|
||||
{ "default", TEXT_PLAIN },
|
||||
{ "default-doc", TEXT_PLAIN },
|
||||
{ "text", TEXT_PLAIN },
|
||||
{ "scribe", TEXT_PLAIN },
|
||||
{ "sgml", TEXT_PLAIN },
|
||||
{ "tex", TEXT_PLAIN },
|
||||
{ "troff", TEXT_PLAIN },
|
||||
{ "c-file", TEXT_PLAIN },
|
||||
{ "h-file", TEXT_PLAIN },
|
||||
{ "readme-file", TEXT_PLAIN },
|
||||
{ "shell-script", TEXT_PLAIN },
|
||||
{ "cshell-script", TEXT_PLAIN },
|
||||
{ "makefile", TEXT_PLAIN },
|
||||
{ "hidden-docs", TEXT_PLAIN },
|
||||
{ "message", MESSAGE_RFC822 },
|
||||
{ "mail-message", MESSAGE_RFC822 },
|
||||
{ "mail-file", TEXT_PLAIN },
|
||||
{ "gif-file", IMAGE_GIF },
|
||||
{ "jpeg-file", IMAGE_JPG },
|
||||
{ "ppm-file", IMAGE_PPM },
|
||||
{ "pgm-file", "image/x-portable-graymap" },
|
||||
{ "pbm-file", "image/x-portable-bitmap" },
|
||||
{ "xpm-file", "image/x-xpixmap" },
|
||||
{ "ilbm-file", "image/ilbm" },
|
||||
{ "tiff-file", "image/tiff" },
|
||||
{ "photocd-file", "image/x-photo-cd" },
|
||||
{ "sun-raster", "image/x-sun-raster" },
|
||||
{ "audio-file", AUDIO_BASIC },
|
||||
{ "postscript", APPLICATION_POSTSCRIPT },
|
||||
{ "postscript-file", APPLICATION_POSTSCRIPT },
|
||||
{ "framemaker-document", "application/x-framemaker" },
|
||||
{ "sundraw-document", "application/x-sun-draw" },
|
||||
{ "sunpaint-document", "application/x-sun-paint" },
|
||||
{ "sunwrite-document", "application/x-sun-write" },
|
||||
{ "islanddraw-document", "application/x-island-draw" },
|
||||
{ "islandpaint-document", "application/x-island-paint" },
|
||||
{ "islandwrite-document", "application/x-island-write" },
|
||||
{ "sun-executable", APPLICATION_OCTET_STREAM },
|
||||
{ "default-app", APPLICATION_OCTET_STREAM },
|
||||
{ 0, 0 }};
|
||||
for (i = 0; sun_types[i].in; i++)
|
||||
if (!nsCRT::strcasecmp(sun_data_type, sun_types[i].in))
|
||||
{
|
||||
mime_ct = sun_types[i].out;
|
||||
break;
|
||||
}
|
||||
}
|
||||
These are the magic types used by MailTool that I can determine.
|
||||
The only actual written spec I've found only listed the first few.
|
||||
The rest were found by inspection (both of real-world messages,
|
||||
and by running `strings' on the MailTool binary, and on the file
|
||||
/usr/openwin/lib/cetables/cetables (the "Class Engine", Sun's
|
||||
equivalent to .mailcap and mime.types.)
|
||||
*/
|
||||
{ "default", TEXT_PLAIN },
|
||||
{ "default-doc", TEXT_PLAIN },
|
||||
{ "text", TEXT_PLAIN },
|
||||
{ "scribe", TEXT_PLAIN },
|
||||
{ "sgml", TEXT_PLAIN },
|
||||
{ "tex", TEXT_PLAIN },
|
||||
{ "troff", TEXT_PLAIN },
|
||||
{ "c-file", TEXT_PLAIN },
|
||||
{ "h-file", TEXT_PLAIN },
|
||||
{ "readme-file", TEXT_PLAIN },
|
||||
{ "shell-script", TEXT_PLAIN },
|
||||
{ "cshell-script", TEXT_PLAIN },
|
||||
{ "makefile", TEXT_PLAIN },
|
||||
{ "hidden-docs", TEXT_PLAIN },
|
||||
{ "message", MESSAGE_RFC822 },
|
||||
{ "mail-message", MESSAGE_RFC822 },
|
||||
{ "mail-file", TEXT_PLAIN },
|
||||
{ "gif-file", IMAGE_GIF },
|
||||
{ "jpeg-file", IMAGE_JPG },
|
||||
{ "ppm-file", IMAGE_PPM },
|
||||
{ "pgm-file", "image/x-portable-graymap" },
|
||||
{ "pbm-file", "image/x-portable-bitmap" },
|
||||
{ "xpm-file", "image/x-xpixmap" },
|
||||
{ "ilbm-file", "image/ilbm" },
|
||||
{ "tiff-file", "image/tiff" },
|
||||
{ "photocd-file", "image/x-photo-cd" },
|
||||
{ "sun-raster", "image/x-sun-raster" },
|
||||
{ "audio-file", AUDIO_BASIC },
|
||||
{ "postscript", APPLICATION_POSTSCRIPT },
|
||||
{ "postscript-file", APPLICATION_POSTSCRIPT },
|
||||
{ "framemaker-document", "application/x-framemaker" },
|
||||
{ "sundraw-document", "application/x-sun-draw" },
|
||||
{ "sunpaint-document", "application/x-sun-paint" },
|
||||
{ "sunwrite-document", "application/x-sun-write" },
|
||||
{ "islanddraw-document", "application/x-island-draw" },
|
||||
{ "islandpaint-document", "application/x-island-paint" },
|
||||
{ "islandwrite-document", "application/x-island-write" },
|
||||
{ "sun-executable", APPLICATION_OCTET_STREAM },
|
||||
{ "default-app", APPLICATION_OCTET_STREAM },
|
||||
{ 0, 0 }};
|
||||
for (i = 0; sun_types[i].in; i++)
|
||||
if (!PL_strcasecmp(sun_data_type, sun_types[i].in))
|
||||
{
|
||||
mime_ct = sun_types[i].out;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we didn't find a type, look at the extension on the file name.
|
||||
*/
|
||||
if (!mime_ct &&
|
||||
obj->options &&
|
||||
obj->options->file_type_fn)
|
||||
{
|
||||
char *name = MimeHeaders_get_name(mult->hdrs, obj->options);
|
||||
if (name)
|
||||
{
|
||||
mime_ct2 = obj->options->file_type_fn(name,
|
||||
obj->options->stream_closure);
|
||||
mime_ct = mime_ct2;
|
||||
PR_Free(name);
|
||||
if (!mime_ct2 || !nsCRT::strcasecmp (mime_ct2, UNKNOWN_CONTENT_TYPE))
|
||||
{
|
||||
PR_FREEIF(mime_ct2);
|
||||
mime_ct = APPLICATION_OCTET_STREAM;
|
||||
}
|
||||
}
|
||||
}
|
||||
obj->options &&
|
||||
obj->options->file_type_fn)
|
||||
{
|
||||
char *name = MimeHeaders_get_name(mult->hdrs, obj->options);
|
||||
if (name)
|
||||
{
|
||||
mime_ct2 = obj->options->file_type_fn(name,
|
||||
obj->options->stream_closure);
|
||||
mime_ct = mime_ct2;
|
||||
PR_Free(name);
|
||||
if (!mime_ct2 || !PL_strcasecmp (mime_ct2, UNKNOWN_CONTENT_TYPE))
|
||||
{
|
||||
PR_FREEIF(mime_ct2);
|
||||
mime_ct = APPLICATION_OCTET_STREAM;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!mime_ct)
|
||||
mime_ct = APPLICATION_OCTET_STREAM;
|
||||
mime_ct = APPLICATION_OCTET_STREAM;
|
||||
|
||||
PR_FREEIF(sun_data_type);
|
||||
|
||||
|
||||
/* Convert recognised Sun encodings to the corresponding MIME encodings.
|
||||
However, if the X-Sun-Encoding-Info field contains more than one
|
||||
encoding (that is, contains a comma) then assign it the encoding of
|
||||
the *rightmost* element in the list; and change its Content-Type to
|
||||
application/octet-stream. Examples:
|
||||
However, if the X-Sun-Encoding-Info field contains more than one
|
||||
encoding (that is, contains a comma) then assign it the encoding of
|
||||
the *rightmost* element in the list; and change its Content-Type to
|
||||
application/octet-stream. Examples:
|
||||
|
||||
Sun Type: Translates To:
|
||||
================== ====================
|
||||
@@ -244,102 +244,102 @@ MimeSunAttachment_create_child(MimeObject *obj)
|
||||
*/
|
||||
|
||||
sun_data_type = (mult->hdrs
|
||||
? MimeHeaders_get (mult->hdrs, HEADER_X_SUN_ENCODING_INFO,
|
||||
PR_FALSE,PR_FALSE)
|
||||
: 0);
|
||||
? MimeHeaders_get (mult->hdrs, HEADER_X_SUN_ENCODING_INFO,
|
||||
PR_FALSE,PR_FALSE)
|
||||
: 0);
|
||||
sun_enc_info = sun_data_type;
|
||||
|
||||
|
||||
/* this "adpcm-compress" pseudo-encoding is some random junk that
|
||||
MailTool adds to the encoding description of .AU files: we can
|
||||
ignore it if it is the leftmost element of the encoding field.
|
||||
(It looks like it's created via `audioconvert -f g721'. Why?
|
||||
Who knows.)
|
||||
MailTool adds to the encoding description of .AU files: we can
|
||||
ignore it if it is the leftmost element of the encoding field.
|
||||
(It looks like it's created via `audioconvert -f g721'. Why?
|
||||
Who knows.)
|
||||
*/
|
||||
if (sun_enc_info && !nsCRT::strncasecmp (sun_enc_info, "adpcm-compress", 14))
|
||||
{
|
||||
sun_enc_info += 14;
|
||||
while (nsCRT::IsAsciiSpace(*sun_enc_info) || *sun_enc_info == ',')
|
||||
sun_enc_info++;
|
||||
}
|
||||
if (sun_enc_info && !PL_strncasecmp (sun_enc_info, "adpcm-compress", 14))
|
||||
{
|
||||
sun_enc_info += 14;
|
||||
while (IS_SPACE(*sun_enc_info) || *sun_enc_info == ',')
|
||||
sun_enc_info++;
|
||||
}
|
||||
|
||||
/* Extract the last element of the encoding field, changing the content
|
||||
type if necessary (as described above.)
|
||||
type if necessary (as described above.)
|
||||
*/
|
||||
if (sun_enc_info && *sun_enc_info)
|
||||
{
|
||||
const char *prev;
|
||||
const char *end = PL_strrchr(sun_enc_info, ',');
|
||||
if (end)
|
||||
{
|
||||
const char *start = sun_enc_info;
|
||||
sun_enc_info = end + 1;
|
||||
while (nsCRT::IsAsciiSpace(*sun_enc_info))
|
||||
sun_enc_info++;
|
||||
for (prev = end-1; prev > start && *prev != ','; prev--)
|
||||
;
|
||||
if (*prev == ',') prev++;
|
||||
{
|
||||
const char *prev;
|
||||
const char *end = PL_strrchr(sun_enc_info, ',');
|
||||
if (end)
|
||||
{
|
||||
const char *start = sun_enc_info;
|
||||
sun_enc_info = end + 1;
|
||||
while (IS_SPACE(*sun_enc_info))
|
||||
sun_enc_info++;
|
||||
for (prev = end-1; prev > start && *prev != ','; prev--)
|
||||
;
|
||||
if (*prev == ',') prev++;
|
||||
|
||||
if (!nsCRT::strncasecmp (prev, "uuencode", end-prev))
|
||||
mime_ct = APPLICATION_UUENCODE;
|
||||
else if (!nsCRT::strncasecmp (prev, "gzip", end-prev))
|
||||
mime_ct = APPLICATION_GZIP;
|
||||
else if (!nsCRT::strncasecmp (prev, "compress", end-prev))
|
||||
mime_ct = APPLICATION_COMPRESS;
|
||||
else if (!nsCRT::strncasecmp (prev, "default-compress", end-prev))
|
||||
mime_ct = APPLICATION_COMPRESS;
|
||||
else
|
||||
mime_ct = APPLICATION_OCTET_STREAM;
|
||||
}
|
||||
}
|
||||
if (!PL_strncasecmp (prev, "uuencode", end-prev))
|
||||
mime_ct = APPLICATION_UUENCODE;
|
||||
else if (!PL_strncasecmp (prev, "gzip", end-prev))
|
||||
mime_ct = APPLICATION_GZIP;
|
||||
else if (!PL_strncasecmp (prev, "compress", end-prev))
|
||||
mime_ct = APPLICATION_COMPRESS;
|
||||
else if (!PL_strncasecmp (prev, "default-compress", end-prev))
|
||||
mime_ct = APPLICATION_COMPRESS;
|
||||
else
|
||||
mime_ct = APPLICATION_OCTET_STREAM;
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert the remaining Sun encoding to a MIME encoding.
|
||||
If it isn't known, change the content-type instead.
|
||||
If it isn't known, change the content-type instead.
|
||||
*/
|
||||
if (!sun_enc_info || !*sun_enc_info)
|
||||
;
|
||||
else if (!nsCRT::strcasecmp(sun_enc_info,"compress")) mime_cte = ENCODING_COMPRESS;
|
||||
else if (!nsCRT::strcasecmp(sun_enc_info,"uuencode")) mime_cte = ENCODING_UUENCODE;
|
||||
else if (!nsCRT::strcasecmp(sun_enc_info,"gzip")) mime_cte = ENCODING_GZIP;
|
||||
else mime_ct = APPLICATION_OCTET_STREAM;
|
||||
;
|
||||
else if (!PL_strcasecmp(sun_enc_info,"compress")) mime_cte = ENCODING_COMPRESS;
|
||||
else if (!PL_strcasecmp(sun_enc_info,"uuencode")) mime_cte = ENCODING_UUENCODE;
|
||||
else if (!PL_strcasecmp(sun_enc_info,"gzip")) mime_cte = ENCODING_GZIP;
|
||||
else mime_ct = APPLICATION_OCTET_STREAM;
|
||||
|
||||
PR_FREEIF(sun_data_type);
|
||||
|
||||
|
||||
/* Now that we know its type and encoding, create a MimeObject to represent
|
||||
this part.
|
||||
this part.
|
||||
*/
|
||||
child = mime_create(mime_ct, mult->hdrs, obj->options);
|
||||
if (!child)
|
||||
{
|
||||
status = MIME_OUT_OF_MEMORY;
|
||||
goto FAIL;
|
||||
}
|
||||
{
|
||||
status = MIME_OUT_OF_MEMORY;
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
/* Fake out the child's content-type and encoding (it probably doesn't have
|
||||
one right now, because the X-Sun- headers aren't generally recognised by
|
||||
the rest of this library.)
|
||||
one right now, because the X-Sun- headers aren't generally recognised by
|
||||
the rest of this library.)
|
||||
*/
|
||||
PR_FREEIF(child->content_type);
|
||||
PR_FREEIF(child->encoding);
|
||||
PR_ASSERT(mime_ct);
|
||||
child->content_type = (mime_ct ? nsCRT::strdup(mime_ct) : 0);
|
||||
child->encoding = (mime_cte ? nsCRT::strdup(mime_cte) : 0);
|
||||
child->content_type = (mime_ct ? strdup(mime_ct) : 0);
|
||||
child->encoding = (mime_cte ? strdup(mime_cte) : 0);
|
||||
|
||||
status = ((MimeContainerClass *) obj->clazz)->add_child(obj, child);
|
||||
if (status < 0)
|
||||
{
|
||||
mime_free(child);
|
||||
child = 0;
|
||||
goto FAIL;
|
||||
}
|
||||
{
|
||||
mime_free(child);
|
||||
child = 0;
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
/* Sun attachments always have separators between parts. */
|
||||
status = MimeObject_write_separator(obj);
|
||||
if (status < 0) goto FAIL;
|
||||
|
||||
/* And now that we've added this new object to our list of
|
||||
children, start its parser going. */
|
||||
children, start its parser going. */
|
||||
status = child->clazz->parse_begin(child);
|
||||
if (status < 0) goto FAIL;
|
||||
|
||||
@@ -352,18 +352,18 @@ MimeSunAttachment_create_child(MimeObject *obj)
|
||||
|
||||
static int
|
||||
MimeSunAttachment_parse_child_line (MimeObject *obj, const char *line, PRInt32 length,
|
||||
PRBool first_line_p)
|
||||
PRBool first_line_p)
|
||||
{
|
||||
MimeContainer *cont = (MimeContainer *) obj;
|
||||
MimeObject *kid;
|
||||
|
||||
/* This is simpler than MimeMultipart->parse_child_line in that it doesn't
|
||||
play games about body parts without trailing newlines.
|
||||
play games about body parts without trailing newlines.
|
||||
*/
|
||||
|
||||
PR_ASSERT(cont->nchildren > 0);
|
||||
if (cont->nchildren <= 0)
|
||||
return -1;
|
||||
return -1;
|
||||
|
||||
kid = cont->children[cont->nchildren-1];
|
||||
PR_ASSERT(kid);
|
||||
|
||||
@@ -51,7 +51,6 @@
|
||||
#include "prlog.h"
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIServiceManager.h"
|
||||
@@ -62,7 +61,7 @@
|
||||
|
||||
#define MIME_SUPERCLASS mimeLeafClass
|
||||
MimeDefClass(MimeInlineText, MimeInlineTextClass, mimeInlineTextClass,
|
||||
&MIME_SUPERCLASS);
|
||||
&MIME_SUPERCLASS);
|
||||
|
||||
static int MimeInlineText_initialize (MimeObject *);
|
||||
static void MimeInlineText_finalize (MimeObject *);
|
||||
@@ -115,7 +114,7 @@ static int MimeInlineText_initializeCharset(MimeObject *obj)
|
||||
{
|
||||
if (obj->options && obj->options->override_charset)
|
||||
{
|
||||
text->charset = nsCRT::strdup(obj->options->default_charset);
|
||||
text->charset = strdup(obj->options->default_charset);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -155,7 +154,7 @@ static int MimeInlineText_initializeCharset(MimeObject *obj)
|
||||
}
|
||||
|
||||
if (obj->options && obj->options->default_charset)
|
||||
text->charset = nsCRT::strdup(obj->options->default_charset);
|
||||
text->charset = strdup(obj->options->default_charset);
|
||||
else
|
||||
{
|
||||
if (NS_SUCCEEDED(res))
|
||||
@@ -165,7 +164,7 @@ static int MimeInlineText_initializeCharset(MimeObject *obj)
|
||||
text->charset = ToNewUTF8String(value);
|
||||
}
|
||||
else
|
||||
text->charset = nsCRT::strdup("");
|
||||
text->charset = strdup("");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -269,10 +268,10 @@ MimeInlineText_parse_end (MimeObject *obj, PRBool abort_p)
|
||||
MimeInlineText *text = (MimeInlineText *) obj;
|
||||
|
||||
if (obj->parsed_p)
|
||||
{
|
||||
PR_ASSERT(obj->closed_p);
|
||||
return 0;
|
||||
}
|
||||
{
|
||||
PR_ASSERT(obj->closed_p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* We won't be needing this buffer any more; nuke it. */
|
||||
PR_FREEIF(text->cbuffer);
|
||||
@@ -312,10 +311,10 @@ MimeInlineText_rot13_line (MimeObject *obj, char *line, PRInt32 length)
|
||||
s = (unsigned char *) line;
|
||||
end = s + length;
|
||||
while (s < end)
|
||||
{
|
||||
*s = MimeInlineText_rot13_table[*s];
|
||||
s++;
|
||||
}
|
||||
{
|
||||
*s = MimeInlineText_rot13_table[*s];
|
||||
s++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -331,28 +330,28 @@ MimeInlineText_parse_decoded_buffer (const char *buf, PRInt32 size, MimeObject *
|
||||
if (!obj->options) return -1;
|
||||
|
||||
/* If we're supposed to write this object, but aren't supposed to convert
|
||||
it to HTML, simply pass it through unaltered. */
|
||||
it to HTML, simply pass it through unaltered. */
|
||||
if (!obj->options->write_html_p && obj->options->format_out != nsMimeOutput::nsMimeMessageAttach)
|
||||
return MimeObject_write(obj, buf, size, PR_TRUE);
|
||||
return MimeObject_write(obj, buf, size, PR_TRUE);
|
||||
|
||||
/* This is just like the parse_decoded_buffer method we inherit from the
|
||||
MimeLeaf class, except that we line-buffer to our own wrapper on the
|
||||
`parse_line' method instead of calling the `parse_line' method directly.
|
||||
MimeLeaf class, except that we line-buffer to our own wrapper on the
|
||||
`parse_line' method instead of calling the `parse_line' method directly.
|
||||
*/
|
||||
return mime_LineBuffer (buf, size,
|
||||
&obj->ibuffer, &obj->ibuffer_size, &obj->ibuffer_fp,
|
||||
PR_TRUE,
|
||||
((int (*PR_CALLBACK) (char *, PRInt32, void *))
|
||||
/* This cast is to turn void into MimeObject */
|
||||
MimeInlineText_rotate_convert_and_parse_line),
|
||||
obj);
|
||||
&obj->ibuffer, &obj->ibuffer_size, &obj->ibuffer_fp,
|
||||
PR_TRUE,
|
||||
((int (*PR_CALLBACK) (char *, PRInt32, void *))
|
||||
/* This cast is to turn void into MimeObject */
|
||||
MimeInlineText_rotate_convert_and_parse_line),
|
||||
obj);
|
||||
}
|
||||
|
||||
|
||||
#define MimeInlineText_grow_cbuffer(text, desired_size) \
|
||||
(((desired_size) >= (text)->cbuffer_size) ? \
|
||||
mime_GrowBuffer ((desired_size), sizeof(char), 100, \
|
||||
&(text)->cbuffer, &(text)->cbuffer_size) \
|
||||
&(text)->cbuffer, &(text)->cbuffer_size) \
|
||||
: 0)
|
||||
|
||||
static int
|
||||
@@ -371,13 +370,13 @@ MimeInlineText_convert_and_parse_line(char *line, PRInt32 length, MimeObject *ob
|
||||
MimeInlineTextHTML *textHTML = (MimeInlineTextHTML *) obj;
|
||||
if (textHTML->charset &&
|
||||
*textHTML->charset &&
|
||||
nsCRT::strcmp(textHTML->charset, text->charset))
|
||||
strcmp(textHTML->charset, text->charset))
|
||||
{
|
||||
//if meta tag specified charset is different from our detected result, use meta charset.
|
||||
//but we don't want to redo previous lines
|
||||
MIME_get_unicode_decoder(textHTML->charset, getter_AddRefs(text->inputDecoder));
|
||||
PR_FREEIF(text->charset);
|
||||
text->charset = nsCRT::strdup(textHTML->charset);
|
||||
text->charset = strdup(textHTML->charset);
|
||||
|
||||
//update MsgWindow charset if we are instructed to do so
|
||||
if (text->needUpdateMsgWinCharset && *text->charset)
|
||||
@@ -396,22 +395,22 @@ MimeInlineText_convert_and_parse_line(char *line, PRInt32 length, MimeObject *ob
|
||||
if (text->utf8Encoder == nsnull)
|
||||
MIME_get_unicode_encoder("UTF-8", getter_AddRefs(text->utf8Encoder));
|
||||
|
||||
PRBool useInputCharsetConverter = obj->options->m_inputCharsetToUnicodeDecoder && !nsCRT::strcasecmp(text->charset, obj->options->charsetForCachedInputDecoder.get());
|
||||
PRBool useInputCharsetConverter = obj->options->m_inputCharsetToUnicodeDecoder && !PL_strcasecmp(text->charset, obj->options->charsetForCachedInputDecoder.get());
|
||||
|
||||
if (useInputCharsetConverter)
|
||||
status = obj->options->charset_conversion_fn(line, length,
|
||||
text->charset,
|
||||
"UTF-8",
|
||||
&converted,
|
||||
&converted_len,
|
||||
"UTF-8",
|
||||
&converted,
|
||||
&converted_len,
|
||||
obj->options->stream_closure, obj->options->m_inputCharsetToUnicodeDecoder,
|
||||
obj->options->m_unicodeToUTF8Encoder);
|
||||
else
|
||||
status = obj->options->charset_conversion_fn(line, length,
|
||||
text->charset,
|
||||
"UTF-8",
|
||||
&converted,
|
||||
&converted_len,
|
||||
"UTF-8",
|
||||
&converted,
|
||||
&converted_len,
|
||||
obj->options->stream_closure, (nsIUnicodeDecoder*)text->inputDecoder,
|
||||
(nsIUnicodeEncoder*)text->utf8Encoder);
|
||||
|
||||
@@ -428,7 +427,7 @@ MimeInlineText_convert_and_parse_line(char *line, PRInt32 length, MimeObject *ob
|
||||
}
|
||||
|
||||
/* Now that the line has been converted, call the subclass's parse_line
|
||||
method with the decoded data. */
|
||||
method with the decoded data. */
|
||||
status = obj->clazz->parse_line(line, length, obj);
|
||||
PR_FREEIF(converted);
|
||||
|
||||
@@ -459,7 +458,7 @@ MimeInlineText_open_dam(char *line, PRInt32 length, MimeObject *obj)
|
||||
//set the charset for this obj
|
||||
if (NS_SUCCEEDED(res) && detectedCharset && *detectedCharset) {
|
||||
PR_FREEIF(text->charset);
|
||||
text->charset = nsCRT::strdup(detectedCharset);
|
||||
text->charset = strdup(detectedCharset);
|
||||
|
||||
//update MsgWindow charset if we are instructed to do so
|
||||
if (text->needUpdateMsgWinCharset && *text->charset)
|
||||
@@ -496,7 +495,7 @@ MimeInlineText_open_dam(char *line, PRInt32 length, MimeObject *obj)
|
||||
|
||||
static int
|
||||
MimeInlineText_rotate_convert_and_parse_line(char *line, PRInt32 length,
|
||||
MimeObject *obj)
|
||||
MimeObject *obj)
|
||||
{
|
||||
int status = 0;
|
||||
MimeInlineTextClass *textc = (MimeInlineTextClass *) obj->clazz;
|
||||
@@ -505,12 +504,12 @@ MimeInlineText_rotate_convert_and_parse_line(char *line, PRInt32 length,
|
||||
if (obj->closed_p) return -1;
|
||||
|
||||
/* Rotate the line, if desired (this happens on the raw data, before any
|
||||
charset conversion.) */
|
||||
charset conversion.) */
|
||||
if (obj->options && obj->options->rot13_p)
|
||||
{
|
||||
status = textc->rot13_line(obj, line, length);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
{
|
||||
status = textc->rot13_line(obj, line, length);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
|
||||
// Now convert to the canonical charset, if desired.
|
||||
//
|
||||
@@ -526,7 +525,7 @@ MimeInlineText_rotate_convert_and_parse_line(char *line, PRInt32 length,
|
||||
(!obj->options->force_user_charset) &&
|
||||
(doConvert)
|
||||
)
|
||||
{
|
||||
{
|
||||
MimeInlineText *text = (MimeInlineText *) obj;
|
||||
|
||||
if (!text->initializeCharset)
|
||||
@@ -558,7 +557,7 @@ MimeInlineText_rotate_convert_and_parse_line(char *line, PRInt32 length,
|
||||
}
|
||||
else
|
||||
status = MimeInlineText_convert_and_parse_line(line, length, obj);
|
||||
}
|
||||
}
|
||||
else
|
||||
status = obj->clazz->parse_line(line, length, obj);
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ MimeInlineTextHTML_parse_begin (MimeObject *obj)
|
||||
|
||||
for (in = base_hdr; *in; in++)
|
||||
/* ignore whitespace and quotes */
|
||||
if (!nsCRT::IsAsciiSpace(*in) && *in != '"')
|
||||
if (!IS_SPACE(*in) && *in != '"')
|
||||
*out++ = *in;
|
||||
|
||||
/* Close the tag and argument. */
|
||||
@@ -193,8 +193,8 @@ MimeInlineTextHTML_parse_line (const char *line, PRInt32 length, MimeObject *obj
|
||||
// 6 == strlen("UTF-16") or strlen("UTF-32"), this will cover
|
||||
// UTF-16, UTF-16BE, UTF-16LE, UTF-32, UTF-32BE, UTF-32LE
|
||||
if ((charset != nsnull) &&
|
||||
nsCRT::strncasecmp(charset, "UTF-16", 6) &&
|
||||
nsCRT::strncasecmp(charset, "UTF-32", 6))
|
||||
PL_strncasecmp(charset, "UTF-16", 6) &&
|
||||
PL_strncasecmp(charset, "UTF-32", 6))
|
||||
{
|
||||
textHTML->charset = charset;
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ MimeInlineTextPlainFlowed_parse_begin (MimeObject *obj)
|
||||
(content_type_row
|
||||
? MimeHeaders_get_parameter(content_type_row, "delsp", NULL,NULL)
|
||||
: 0);
|
||||
((MimeInlineTextPlainFlowed *)obj)->delSp = content_type_delsp && !nsCRT::strcasecmp(content_type_delsp, "yes");
|
||||
((MimeInlineTextPlainFlowed *)obj)->delSp = content_type_delsp && !PL_strcasecmp(content_type_delsp, "yes");
|
||||
PR_Free(content_type_delsp);
|
||||
PR_Free(content_type_row);
|
||||
|
||||
@@ -343,7 +343,7 @@ MimeInlineTextPlainFlowed_parse_line (const char *aLine, PRInt32 length, MimeObj
|
||||
(quote marks and) a space count as empty */
|
||||
{
|
||||
flowed = PR_TRUE;
|
||||
sigSeparator = (index - (linep - line) + 1 == 3) && !nsCRT::strncmp(linep, "-- ", 3);
|
||||
sigSeparator = (index - (linep - line) + 1 == 3) && !strncmp(linep, "-- ", 3);
|
||||
if (((MimeInlineTextPlainFlowed *) obj)->delSp && ! sigSeparator)
|
||||
/* If line is flowed and DelSp=yes, logically
|
||||
delete trailing space. Line consisting of
|
||||
@@ -396,7 +396,7 @@ MimeInlineTextPlainFlowed_parse_line (const char *aLine, PRInt32 length, MimeObj
|
||||
((MimeInlineTextClass*)&mimeInlineTextClass)->initialize_charset(obj);
|
||||
mailCharset = inlinetext->charset;
|
||||
if (mailCharset && *mailCharset) {
|
||||
rv = nsMsgI18NConvertToUnicode(mailCharset, nsDependentCString(inputStr), lineSource);
|
||||
rv = nsMsgI18NConvertToUnicode(mailCharset, PromiseFlatCString(inputStr), lineSource);
|
||||
NS_ENSURE_SUCCESS(rv, -1);
|
||||
}
|
||||
else // this probably never happens...
|
||||
|
||||
@@ -38,13 +38,12 @@
|
||||
#include "mimebuf.h"
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
#include "nsCRT.h"
|
||||
#include "prlog.h"
|
||||
#include "msgCore.h"
|
||||
|
||||
#define MIME_SUPERCLASS mimeInlineTextClass
|
||||
MimeDefClass(MimeInlineTextRichtext, MimeInlineTextRichtextClass,
|
||||
mimeInlineTextRichtextClass, &MIME_SUPERCLASS);
|
||||
mimeInlineTextRichtextClass, &MIME_SUPERCLASS);
|
||||
|
||||
static int MimeInlineTextRichtext_parse_line (const char *, PRInt32, MimeObject *);
|
||||
static int MimeInlineTextRichtext_parse_begin (MimeObject *);
|
||||
@@ -66,34 +65,34 @@ MimeInlineTextRichtextClassInitialize(MimeInlineTextRichtextClass *clazz)
|
||||
*/
|
||||
int
|
||||
MimeRichtextConvert (const char *line, PRInt32 length,
|
||||
int (*output_fn) (const char *buf, PRInt32 size, void *closure),
|
||||
void *closure,
|
||||
char **obufferP,
|
||||
PRInt32 *obuffer_sizeP,
|
||||
PRBool enriched_p)
|
||||
int (*output_fn) (const char *buf, PRInt32 size, void *closure),
|
||||
void *closure,
|
||||
char **obufferP,
|
||||
PRInt32 *obuffer_sizeP,
|
||||
PRBool enriched_p)
|
||||
{
|
||||
/* RFC 1341 (the original MIME spec) defined text/richtext.
|
||||
RFC 1563 superceded text/richtext with text/enriched.
|
||||
The changes from text/richtext to text/enriched are:
|
||||
- CRLF semantics are different
|
||||
- << maps to <
|
||||
- These tags were added:
|
||||
<VERBATIM>, <NOFILL>, <PARAM>, <FLUSHBOTH>
|
||||
- These tags were removed:
|
||||
<COMMENT>, <OUTDENT>, <OUTDENTRIGHT>, <SAMEPAGE>, <SUBSCRIPT>,
|
||||
RFC 1563 superceded text/richtext with text/enriched.
|
||||
The changes from text/richtext to text/enriched are:
|
||||
- CRLF semantics are different
|
||||
- << maps to <
|
||||
- These tags were added:
|
||||
<VERBATIM>, <NOFILL>, <PARAM>, <FLUSHBOTH>
|
||||
- These tags were removed:
|
||||
<COMMENT>, <OUTDENT>, <OUTDENTRIGHT>, <SAMEPAGE>, <SUBSCRIPT>,
|
||||
<SUPERSCRIPT>, <HEADING>, <FOOTING>, <PARAGRAPH>, <SIGNATURE>,
|
||||
<LT>, <NL>, <NP>
|
||||
This method implements them both.
|
||||
<LT>, <NL>, <NP>
|
||||
This method implements them both.
|
||||
|
||||
draft-resnick-text-enriched-03.txt is a proposed update to 1563.
|
||||
- These tags were added:
|
||||
<FONTFAMILY>, <COLOR>, <PARAINDENT>, <LANG>.
|
||||
However, all of these rely on the magic <PARAM> tag, which we
|
||||
don't implement, so we're ignoring all of these.
|
||||
Interesting fact: it's by Peter W. Resnick from Qualcomm (Eudora).
|
||||
And it also says "It is fully expected that other text formatting
|
||||
standards like HTML and SGML will supplant text/enriched in
|
||||
Internet mail."
|
||||
draft-resnick-text-enriched-03.txt is a proposed update to 1563.
|
||||
- These tags were added:
|
||||
<FONTFAMILY>, <COLOR>, <PARAINDENT>, <LANG>.
|
||||
However, all of these rely on the magic <PARAM> tag, which we
|
||||
don't implement, so we're ignoring all of these.
|
||||
Interesting fact: it's by Peter W. Resnick from Qualcomm (Eudora).
|
||||
And it also says "It is fully expected that other text formatting
|
||||
standards like HTML and SGML will supplant text/enriched in
|
||||
Internet mail."
|
||||
*/
|
||||
int status = 0;
|
||||
char *out;
|
||||
@@ -111,20 +110,20 @@ MimeRichtextConvert (const char *line, PRInt32 length,
|
||||
desired_size = (length * BGROWTH) + 1;
|
||||
#undef BGROWTH
|
||||
if (desired_size >= (PRUint32) *obuffer_sizeP)
|
||||
status = mime_GrowBuffer (desired_size, sizeof(char), 1024,
|
||||
obufferP, obuffer_sizeP);
|
||||
status = mime_GrowBuffer (desired_size, sizeof(char), 1024,
|
||||
obufferP, obuffer_sizeP);
|
||||
if (status < 0) return status;
|
||||
|
||||
if (enriched_p)
|
||||
{
|
||||
for (this_start = line; this_start < line + length; this_start++)
|
||||
if (!nsCRT::IsAsciiSpace (*this_start)) break;
|
||||
if (this_start >= line + length) /* blank line */
|
||||
{
|
||||
PL_strcpy (*obufferP, "<BR>");
|
||||
return output_fn (*obufferP, strlen(*obufferP), closure);
|
||||
}
|
||||
}
|
||||
{
|
||||
for (this_start = line; this_start < line + length; this_start++)
|
||||
if (!IS_SPACE (*this_start)) break;
|
||||
if (this_start >= line + length) /* blank line */
|
||||
{
|
||||
PL_strcpy (*obufferP, "<BR>");
|
||||
return output_fn (*obufferP, strlen(*obufferP), closure);
|
||||
}
|
||||
}
|
||||
|
||||
out = *obufferP;
|
||||
*out = 0;
|
||||
@@ -134,199 +133,199 @@ MimeRichtextConvert (const char *line, PRInt32 length,
|
||||
this_start = last_end;
|
||||
this_end = this_start;
|
||||
while (this_end < data_end)
|
||||
{
|
||||
/* Skip forward to next special character. */
|
||||
while (this_start < data_end &&
|
||||
*this_start != '<' && *this_start != '>' &&
|
||||
*this_start != '&')
|
||||
this_start++;
|
||||
{
|
||||
/* Skip forward to next special character. */
|
||||
while (this_start < data_end &&
|
||||
*this_start != '<' && *this_start != '>' &&
|
||||
*this_start != '&')
|
||||
this_start++;
|
||||
|
||||
this_end = this_start;
|
||||
this_end = this_start;
|
||||
|
||||
/* Skip to the end of the tag. */
|
||||
if (this_start < data_end && *this_start == '<')
|
||||
{
|
||||
this_end++;
|
||||
while (this_end < data_end &&
|
||||
!nsCRT::IsAsciiSpace (*this_end) &&
|
||||
*this_end != '<' && *this_end != '>' &&
|
||||
*this_end != '&')
|
||||
this_end++;
|
||||
}
|
||||
/* Skip to the end of the tag. */
|
||||
if (this_start < data_end && *this_start == '<')
|
||||
{
|
||||
this_end++;
|
||||
while (this_end < data_end &&
|
||||
!IS_SPACE(*this_end) &&
|
||||
*this_end != '<' && *this_end != '>' &&
|
||||
*this_end != '&')
|
||||
this_end++;
|
||||
}
|
||||
|
||||
this_end++;
|
||||
this_end++;
|
||||
|
||||
/* Push out the text preceeding the tag. */
|
||||
if (last_end && last_end != this_start)
|
||||
{
|
||||
memcpy (out, last_end, this_start - last_end);
|
||||
out += this_start - last_end;
|
||||
*out = 0;
|
||||
}
|
||||
/* Push out the text preceeding the tag. */
|
||||
if (last_end && last_end != this_start)
|
||||
{
|
||||
memcpy (out, last_end, this_start - last_end);
|
||||
out += this_start - last_end;
|
||||
*out = 0;
|
||||
}
|
||||
|
||||
if (this_start >= data_end)
|
||||
break;
|
||||
else if (*this_start == '&')
|
||||
{
|
||||
PL_strcpy (out, "&"); out += strlen (out);
|
||||
}
|
||||
else if (*this_start == '>')
|
||||
{
|
||||
PL_strcpy (out, ">"); out += strlen (out);
|
||||
}
|
||||
else if (enriched_p &&
|
||||
this_start < data_end + 1 &&
|
||||
this_start[0] == '<' &&
|
||||
this_start[1] == '<')
|
||||
{
|
||||
PL_strcpy (out, "<"); out += strlen (out);
|
||||
}
|
||||
else if (this_start != this_end)
|
||||
{
|
||||
/* Push out this ID. */
|
||||
const char *old = this_start + 1;
|
||||
const char *tag_open = 0;
|
||||
const char *tag_close = 0;
|
||||
if (*old == '/')
|
||||
{
|
||||
/* This is </tag> */
|
||||
old++;
|
||||
}
|
||||
if (this_start >= data_end)
|
||||
break;
|
||||
else if (*this_start == '&')
|
||||
{
|
||||
PL_strcpy (out, "&"); out += strlen (out);
|
||||
}
|
||||
else if (*this_start == '>')
|
||||
{
|
||||
PL_strcpy (out, ">"); out += strlen (out);
|
||||
}
|
||||
else if (enriched_p &&
|
||||
this_start < data_end + 1 &&
|
||||
this_start[0] == '<' &&
|
||||
this_start[1] == '<')
|
||||
{
|
||||
PL_strcpy (out, "<"); out += strlen (out);
|
||||
}
|
||||
else if (this_start != this_end)
|
||||
{
|
||||
/* Push out this ID. */
|
||||
const char *old = this_start + 1;
|
||||
const char *tag_open = 0;
|
||||
const char *tag_close = 0;
|
||||
if (*old == '/')
|
||||
{
|
||||
/* This is </tag> */
|
||||
old++;
|
||||
}
|
||||
|
||||
switch (*old)
|
||||
{
|
||||
case 'b': case 'B':
|
||||
if (!nsCRT::strncasecmp ("BIGGER>", old, 7))
|
||||
tag_open = "<FONT SIZE=\"+1\">", tag_close = "</FONT>";
|
||||
else if (!nsCRT::strncasecmp ("BLINK>", old, 5))
|
||||
/* Of course, both text/richtext and text/enriched must be
|
||||
enhanced *somehow*... Or else what would people think. */
|
||||
tag_open = "<BLINK>", tag_close = "</BLINK>";
|
||||
else if (!nsCRT::strncasecmp ("BOLD>", old, 5))
|
||||
tag_open = "<B>", tag_close = "</B>";
|
||||
break;
|
||||
case 'c': case 'C':
|
||||
if (!nsCRT::strncasecmp ("CENTER>", old, 7))
|
||||
tag_open = "<CENTER>", tag_close = "</CENTER>";
|
||||
else if (!enriched_p &&
|
||||
!nsCRT::strncasecmp ("COMMENT>", old, 8))
|
||||
tag_open = "<!-- ", tag_close = " -->";
|
||||
break;
|
||||
case 'e': case 'E':
|
||||
if (!nsCRT::strncasecmp ("EXCERPT>", old, 8))
|
||||
tag_open = "<BLOCKQUOTE>", tag_close = "</BLOCKQUOTE>";
|
||||
break;
|
||||
case 'f': case 'F':
|
||||
if (!nsCRT::strncasecmp ("FIXED>", old, 6))
|
||||
tag_open = "<TT>", tag_close = "</TT>";
|
||||
else if (enriched_p &&
|
||||
!nsCRT::strncasecmp ("FLUSHBOTH>", old, 10))
|
||||
tag_open = "<P ALIGN=LEFT>", tag_close = "</P>";
|
||||
else if (!nsCRT::strncasecmp ("FLUSHLEFT>", old, 10))
|
||||
tag_open = "<P ALIGN=LEFT>", tag_close = "</P>";
|
||||
else if (!nsCRT::strncasecmp ("FLUSHRIGHT>", old, 11))
|
||||
tag_open = "<P ALIGN=RIGHT>", tag_close = "</P>";
|
||||
else if (!enriched_p &&
|
||||
!nsCRT::strncasecmp ("FOOTING>", old, 8))
|
||||
tag_open = "<H6>", tag_close = "</H6>";
|
||||
break;
|
||||
case 'h': case 'H':
|
||||
if (!enriched_p &&
|
||||
!nsCRT::strncasecmp ("HEADING>", old, 8))
|
||||
tag_open = "<H6>", tag_close = "</H6>";
|
||||
break;
|
||||
case 'i': case 'I':
|
||||
if (!nsCRT::strncasecmp ("INDENT>", old, 7))
|
||||
tag_open = "<UL>", tag_close = "</UL>";
|
||||
else if (!nsCRT::strncasecmp ("INDENTRIGHT>", old, 12))
|
||||
tag_open = 0, tag_close = 0;
|
||||
/* else if (!enriched_p &&
|
||||
!nsCRT::strncasecmp ("ISO-8859-", old, 9))
|
||||
tag_open = 0, tag_close = 0; */
|
||||
else if (!nsCRT::strncasecmp ("ITALIC>", old, 7))
|
||||
tag_open = "<I>", tag_close = "</I>";
|
||||
break;
|
||||
case 'l': case 'L':
|
||||
if (!enriched_p &&
|
||||
!nsCRT::strncasecmp ("LT>", old, 3))
|
||||
tag_open = "<", tag_close = 0;
|
||||
break;
|
||||
case 'n': case 'N':
|
||||
if (!enriched_p &&
|
||||
!nsCRT::strncasecmp ("NL>", old, 3))
|
||||
tag_open = "<BR>", tag_close = 0;
|
||||
if (enriched_p &&
|
||||
!nsCRT::strncasecmp ("NOFILL>", old, 7))
|
||||
tag_open = "<NOBR>", tag_close = "</NOBR>";
|
||||
/* else if (!enriched_p &&
|
||||
!nsCRT::strncasecmp ("NO-OP>", old, 6))
|
||||
tag_open = 0, tag_close = 0; */
|
||||
/* else if (!enriched_p &&
|
||||
!nsCRT::strncasecmp ("NP>", old, 3))
|
||||
tag_open = 0, tag_close = 0; */
|
||||
break;
|
||||
case 'o': case 'O':
|
||||
if (!enriched_p &&
|
||||
!nsCRT::strncasecmp ("OUTDENT>", old, 8))
|
||||
tag_open = 0, tag_close = 0;
|
||||
else if (!enriched_p &&
|
||||
!nsCRT::strncasecmp ("OUTDENTRIGHT>", old, 13))
|
||||
tag_open = 0, tag_close = 0;
|
||||
break;
|
||||
case 'p': case 'P':
|
||||
if (enriched_p &&
|
||||
!nsCRT::strncasecmp ("PARAM>", old, 6))
|
||||
tag_open = "<!-- ", tag_close = " -->";
|
||||
else if (!enriched_p &&
|
||||
!nsCRT::strncasecmp ("PARAGRAPH>", old, 10))
|
||||
tag_open = "<P>", tag_close = 0;
|
||||
break;
|
||||
case 's': case 'S':
|
||||
if (!enriched_p &&
|
||||
!nsCRT::strncasecmp ("SAMEPAGE>", old, 9))
|
||||
tag_open = 0, tag_close = 0;
|
||||
else if (!enriched_p &&
|
||||
!nsCRT::strncasecmp ("SIGNATURE>", old, 10))
|
||||
tag_open = "<I><FONT SIZE=\"-1\">", tag_close = "</FONT></I>";
|
||||
else if (!nsCRT::strncasecmp ("SMALLER>", old, 8))
|
||||
tag_open = "<FONT SIZE=\"-1\">", tag_close = "</FONT>";
|
||||
else if (!enriched_p &&
|
||||
!nsCRT::strncasecmp ("SUBSCRIPT>", old, 10))
|
||||
tag_open = "<SUB>", tag_close = "</SUB>";
|
||||
else if (!enriched_p &&
|
||||
!nsCRT::strncasecmp ("SUPERSCRIPT>", old, 12))
|
||||
tag_open = "<SUP>", tag_close = "</SUP>";
|
||||
break;
|
||||
case 'u': case 'U':
|
||||
if (!nsCRT::strncasecmp ("UNDERLINE>", old, 10))
|
||||
tag_open = "<U>", tag_close = "</U>";
|
||||
/* else if (!enriched_p &&
|
||||
!nsCRT::strncasecmp ("US-ASCII>", old, 10))
|
||||
tag_open = 0, tag_close = 0; */
|
||||
break;
|
||||
case 'v': case 'V':
|
||||
if (enriched_p &&
|
||||
!nsCRT::strncasecmp ("VERBATIM>", old, 9))
|
||||
tag_open = "<PRE>", tag_close = "</PRE>";
|
||||
break;
|
||||
}
|
||||
switch (*old)
|
||||
{
|
||||
case 'b': case 'B':
|
||||
if (!PL_strncasecmp ("BIGGER>", old, 7))
|
||||
tag_open = "<FONT SIZE=\"+1\">", tag_close = "</FONT>";
|
||||
else if (!PL_strncasecmp ("BLINK>", old, 5))
|
||||
/* Of course, both text/richtext and text/enriched must be
|
||||
enhanced *somehow*... Or else what would people think. */
|
||||
tag_open = "<BLINK>", tag_close = "</BLINK>";
|
||||
else if (!PL_strncasecmp ("BOLD>", old, 5))
|
||||
tag_open = "<B>", tag_close = "</B>";
|
||||
break;
|
||||
case 'c': case 'C':
|
||||
if (!PL_strncasecmp ("CENTER>", old, 7))
|
||||
tag_open = "<CENTER>", tag_close = "</CENTER>";
|
||||
else if (!enriched_p &&
|
||||
!PL_strncasecmp ("COMMENT>", old, 8))
|
||||
tag_open = "<!-- ", tag_close = " -->";
|
||||
break;
|
||||
case 'e': case 'E':
|
||||
if (!PL_strncasecmp ("EXCERPT>", old, 8))
|
||||
tag_open = "<BLOCKQUOTE>", tag_close = "</BLOCKQUOTE>";
|
||||
break;
|
||||
case 'f': case 'F':
|
||||
if (!PL_strncasecmp ("FIXED>", old, 6))
|
||||
tag_open = "<TT>", tag_close = "</TT>";
|
||||
else if (enriched_p &&
|
||||
!PL_strncasecmp ("FLUSHBOTH>", old, 10))
|
||||
tag_open = "<P ALIGN=LEFT>", tag_close = "</P>";
|
||||
else if (!PL_strncasecmp ("FLUSHLEFT>", old, 10))
|
||||
tag_open = "<P ALIGN=LEFT>", tag_close = "</P>";
|
||||
else if (!PL_strncasecmp ("FLUSHRIGHT>", old, 11))
|
||||
tag_open = "<P ALIGN=RIGHT>", tag_close = "</P>";
|
||||
else if (!enriched_p &&
|
||||
!PL_strncasecmp ("FOOTING>", old, 8))
|
||||
tag_open = "<H6>", tag_close = "</H6>";
|
||||
break;
|
||||
case 'h': case 'H':
|
||||
if (!enriched_p &&
|
||||
!PL_strncasecmp ("HEADING>", old, 8))
|
||||
tag_open = "<H6>", tag_close = "</H6>";
|
||||
break;
|
||||
case 'i': case 'I':
|
||||
if (!PL_strncasecmp ("INDENT>", old, 7))
|
||||
tag_open = "<UL>", tag_close = "</UL>";
|
||||
else if (!PL_strncasecmp ("INDENTRIGHT>", old, 12))
|
||||
tag_open = 0, tag_close = 0;
|
||||
/* else if (!enriched_p &&
|
||||
!PL_strncasecmp ("ISO-8859-", old, 9))
|
||||
tag_open = 0, tag_close = 0; */
|
||||
else if (!PL_strncasecmp ("ITALIC>", old, 7))
|
||||
tag_open = "<I>", tag_close = "</I>";
|
||||
break;
|
||||
case 'l': case 'L':
|
||||
if (!enriched_p &&
|
||||
!PL_strncasecmp ("LT>", old, 3))
|
||||
tag_open = "<", tag_close = 0;
|
||||
break;
|
||||
case 'n': case 'N':
|
||||
if (!enriched_p &&
|
||||
!PL_strncasecmp ("NL>", old, 3))
|
||||
tag_open = "<BR>", tag_close = 0;
|
||||
if (enriched_p &&
|
||||
!PL_strncasecmp ("NOFILL>", old, 7))
|
||||
tag_open = "<NOBR>", tag_close = "</NOBR>";
|
||||
/* else if (!enriched_p &&
|
||||
!PL_strncasecmp ("NO-OP>", old, 6))
|
||||
tag_open = 0, tag_close = 0; */
|
||||
/* else if (!enriched_p &&
|
||||
!PL_strncasecmp ("NP>", old, 3))
|
||||
tag_open = 0, tag_close = 0; */
|
||||
break;
|
||||
case 'o': case 'O':
|
||||
if (!enriched_p &&
|
||||
!PL_strncasecmp ("OUTDENT>", old, 8))
|
||||
tag_open = 0, tag_close = 0;
|
||||
else if (!enriched_p &&
|
||||
!PL_strncasecmp ("OUTDENTRIGHT>", old, 13))
|
||||
tag_open = 0, tag_close = 0;
|
||||
break;
|
||||
case 'p': case 'P':
|
||||
if (enriched_p &&
|
||||
!PL_strncasecmp ("PARAM>", old, 6))
|
||||
tag_open = "<!-- ", tag_close = " -->";
|
||||
else if (!enriched_p &&
|
||||
!PL_strncasecmp ("PARAGRAPH>", old, 10))
|
||||
tag_open = "<P>", tag_close = 0;
|
||||
break;
|
||||
case 's': case 'S':
|
||||
if (!enriched_p &&
|
||||
!PL_strncasecmp ("SAMEPAGE>", old, 9))
|
||||
tag_open = 0, tag_close = 0;
|
||||
else if (!enriched_p &&
|
||||
!PL_strncasecmp ("SIGNATURE>", old, 10))
|
||||
tag_open = "<I><FONT SIZE=\"-1\">", tag_close = "</FONT></I>";
|
||||
else if (!PL_strncasecmp ("SMALLER>", old, 8))
|
||||
tag_open = "<FONT SIZE=\"-1\">", tag_close = "</FONT>";
|
||||
else if (!enriched_p &&
|
||||
!PL_strncasecmp ("SUBSCRIPT>", old, 10))
|
||||
tag_open = "<SUB>", tag_close = "</SUB>";
|
||||
else if (!enriched_p &&
|
||||
!PL_strncasecmp ("SUPERSCRIPT>", old, 12))
|
||||
tag_open = "<SUP>", tag_close = "</SUP>";
|
||||
break;
|
||||
case 'u': case 'U':
|
||||
if (!PL_strncasecmp ("UNDERLINE>", old, 10))
|
||||
tag_open = "<U>", tag_close = "</U>";
|
||||
/* else if (!enriched_p &&
|
||||
!PL_strncasecmp ("US-ASCII>", old, 10))
|
||||
tag_open = 0, tag_close = 0; */
|
||||
break;
|
||||
case 'v': case 'V':
|
||||
if (enriched_p &&
|
||||
!PL_strncasecmp ("VERBATIM>", old, 9))
|
||||
tag_open = "<PRE>", tag_close = "</PRE>";
|
||||
break;
|
||||
}
|
||||
|
||||
if (this_start[1] == '/')
|
||||
{
|
||||
if (tag_close) PL_strcpy (out, tag_close);
|
||||
out += strlen (out);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tag_open) PL_strcpy (out, tag_open);
|
||||
out += strlen (out);
|
||||
}
|
||||
}
|
||||
if (this_start[1] == '/')
|
||||
{
|
||||
if (tag_close) PL_strcpy (out, tag_close);
|
||||
out += strlen (out);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tag_open) PL_strcpy (out, tag_open);
|
||||
out += strlen (out);
|
||||
}
|
||||
}
|
||||
|
||||
/* now go around again */
|
||||
last_end = this_end;
|
||||
this_start = last_end;
|
||||
}
|
||||
/* now go around again */
|
||||
last_end = this_end;
|
||||
this_start = last_end;
|
||||
}
|
||||
*out = 0;
|
||||
|
||||
return output_fn (*obufferP, out - *obufferP, closure);
|
||||
@@ -337,13 +336,13 @@ static int
|
||||
MimeInlineTextRichtext_parse_line (const char *line, PRInt32 length, MimeObject *obj)
|
||||
{
|
||||
PRBool enriched_p = (((MimeInlineTextRichtextClass *) obj->clazz)
|
||||
->enriched_p);
|
||||
->enriched_p);
|
||||
|
||||
return MimeRichtextConvert (line, length,
|
||||
obj->options->output_fn,
|
||||
obj->options->stream_closure,
|
||||
&obj->obuffer, &obj->obuffer_size,
|
||||
enriched_p);
|
||||
obj->options->output_fn,
|
||||
obj->options->stream_closure,
|
||||
&obj->obuffer, &obj->obuffer_size,
|
||||
enriched_p);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
#include "mimeunty.h"
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
#include "nsCRT.h"
|
||||
#include "prlog.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "msgCore.h"
|
||||
@@ -46,7 +45,7 @@
|
||||
|
||||
#define MIME_SUPERCLASS mimeContainerClass
|
||||
MimeDefClass(MimeUntypedText, MimeUntypedTextClass,
|
||||
mimeUntypedTextClass, &MIME_SUPERCLASS);
|
||||
mimeUntypedTextClass, &MIME_SUPERCLASS);
|
||||
|
||||
static int MimeUntypedText_initialize (MimeObject *);
|
||||
static void MimeUntypedText_finalize (MimeObject *);
|
||||
@@ -54,30 +53,30 @@ static int MimeUntypedText_parse_begin (MimeObject *);
|
||||
static int MimeUntypedText_parse_line (const char *, PRInt32, MimeObject *);
|
||||
|
||||
static int MimeUntypedText_open_subpart (MimeObject *obj,
|
||||
MimeUntypedTextSubpartType ttype,
|
||||
const char *type,
|
||||
const char *enc,
|
||||
const char *name,
|
||||
const char *desc);
|
||||
MimeUntypedTextSubpartType ttype,
|
||||
const char *type,
|
||||
const char *enc,
|
||||
const char *name,
|
||||
const char *desc);
|
||||
static int MimeUntypedText_close_subpart (MimeObject *obj);
|
||||
|
||||
static PRBool MimeUntypedText_uu_begin_line_p(const char *line, PRInt32 length,
|
||||
MimeDisplayOptions *opt,
|
||||
char **type_ret,
|
||||
char **name_ret);
|
||||
MimeDisplayOptions *opt,
|
||||
char **type_ret,
|
||||
char **name_ret);
|
||||
static PRBool MimeUntypedText_uu_end_line_p(const char *line, PRInt32 length);
|
||||
|
||||
static PRBool MimeUntypedText_yenc_begin_line_p(const char *line, PRInt32 length,
|
||||
MimeDisplayOptions *opt,
|
||||
char **type_ret,
|
||||
char **name_ret);
|
||||
MimeDisplayOptions *opt,
|
||||
char **type_ret,
|
||||
char **name_ret);
|
||||
static PRBool MimeUntypedText_yenc_end_line_p(const char *line, PRInt32 length);
|
||||
|
||||
static PRBool MimeUntypedText_binhex_begin_line_p(const char *line,
|
||||
PRInt32 length,
|
||||
MimeDisplayOptions *opt);
|
||||
PRInt32 length,
|
||||
MimeDisplayOptions *opt);
|
||||
static PRBool MimeUntypedText_binhex_end_line_p(const char *line,
|
||||
PRInt32 length);
|
||||
PRInt32 length);
|
||||
|
||||
static int
|
||||
MimeUntypedTextClassInitialize(MimeUntypedTextClass *clazz)
|
||||
@@ -104,15 +103,15 @@ MimeUntypedText_finalize (MimeObject *object)
|
||||
MimeUntypedText *uty = (MimeUntypedText *) object;
|
||||
|
||||
if (uty->open_hdrs)
|
||||
{
|
||||
/* Oops, those shouldn't still be here... */
|
||||
MimeHeaders_free(uty->open_hdrs);
|
||||
uty->open_hdrs = 0;
|
||||
}
|
||||
{
|
||||
/* Oops, those shouldn't still be here... */
|
||||
MimeHeaders_free(uty->open_hdrs);
|
||||
uty->open_hdrs = 0;
|
||||
}
|
||||
|
||||
/* What about the open_subpart? We're gonna have to assume that it
|
||||
is also on the MimeContainer->children list, and will get cleaned
|
||||
up by that class. */
|
||||
is also on the MimeContainer->children list, and will get cleaned
|
||||
up by that class. */
|
||||
|
||||
((MimeObjectClass*)&MIME_SUPERCLASS)->finalize(object);
|
||||
}
|
||||
@@ -135,62 +134,62 @@ MimeUntypedText_parse_line (const char *line, PRInt32 length, MimeObject *obj)
|
||||
if (!line || !*line) return -1;
|
||||
|
||||
/* If we're supposed to write this object, but aren't supposed to convert
|
||||
it to HTML, simply pass it through unaltered. */
|
||||
it to HTML, simply pass it through unaltered. */
|
||||
if (obj->output_p &&
|
||||
obj->options &&
|
||||
!obj->options->write_html_p &&
|
||||
obj->options->output_fn)
|
||||
return MimeObject_write(obj, line, length, PR_TRUE);
|
||||
obj->options &&
|
||||
!obj->options->write_html_p &&
|
||||
obj->options->output_fn)
|
||||
return MimeObject_write(obj, line, length, PR_TRUE);
|
||||
|
||||
|
||||
/* Open a new sub-part if this line demands it.
|
||||
*/
|
||||
if (line[0] == 'b' &&
|
||||
MimeUntypedText_uu_begin_line_p(line, length, obj->options,
|
||||
&type, &name))
|
||||
{
|
||||
/* Close the old part and open a new one. */
|
||||
status = MimeUntypedText_open_subpart (obj,
|
||||
MimeUntypedTextSubpartTypeUUE,
|
||||
type, ENCODING_UUENCODE,
|
||||
name, NULL);
|
||||
PR_FREEIF(name);
|
||||
PR_FREEIF(type);
|
||||
if (status < 0) return status;
|
||||
begin_line_p = PR_TRUE;
|
||||
}
|
||||
MimeUntypedText_uu_begin_line_p(line, length, obj->options,
|
||||
&type, &name))
|
||||
{
|
||||
/* Close the old part and open a new one. */
|
||||
status = MimeUntypedText_open_subpart (obj,
|
||||
MimeUntypedTextSubpartTypeUUE,
|
||||
type, ENCODING_UUENCODE,
|
||||
name, NULL);
|
||||
PR_FREEIF(name);
|
||||
PR_FREEIF(type);
|
||||
if (status < 0) return status;
|
||||
begin_line_p = PR_TRUE;
|
||||
}
|
||||
|
||||
else if (line[0] == '=' &&
|
||||
MimeUntypedText_yenc_begin_line_p(line, length, obj->options,
|
||||
&type, &name))
|
||||
{
|
||||
/* Close the old part and open a new one. */
|
||||
status = MimeUntypedText_open_subpart (obj,
|
||||
MimeUntypedTextSubpartTypeYEnc,
|
||||
type, ENCODING_YENCODE,
|
||||
name, NULL);
|
||||
PR_FREEIF(name);
|
||||
PR_FREEIF(type);
|
||||
if (status < 0) return status;
|
||||
begin_line_p = PR_TRUE;
|
||||
}
|
||||
MimeUntypedText_yenc_begin_line_p(line, length, obj->options,
|
||||
&type, &name))
|
||||
{
|
||||
/* Close the old part and open a new one. */
|
||||
status = MimeUntypedText_open_subpart (obj,
|
||||
MimeUntypedTextSubpartTypeYEnc,
|
||||
type, ENCODING_YENCODE,
|
||||
name, NULL);
|
||||
PR_FREEIF(name);
|
||||
PR_FREEIF(type);
|
||||
if (status < 0) return status;
|
||||
begin_line_p = PR_TRUE;
|
||||
}
|
||||
|
||||
else if (line[0] == '(' && line[1] == 'T' &&
|
||||
MimeUntypedText_binhex_begin_line_p(line, length, obj->options))
|
||||
{
|
||||
/* Close the old part and open a new one. */
|
||||
status = MimeUntypedText_open_subpart (obj,
|
||||
MimeUntypedTextSubpartTypeBinhex,
|
||||
APPLICATION_BINHEX, NULL,
|
||||
NULL, NULL);
|
||||
if (status < 0) return status;
|
||||
begin_line_p = PR_TRUE;
|
||||
}
|
||||
MimeUntypedText_binhex_begin_line_p(line, length, obj->options))
|
||||
{
|
||||
/* Close the old part and open a new one. */
|
||||
status = MimeUntypedText_open_subpart (obj,
|
||||
MimeUntypedTextSubpartTypeBinhex,
|
||||
APPLICATION_BINHEX, NULL,
|
||||
NULL, NULL);
|
||||
if (status < 0) return status;
|
||||
begin_line_p = PR_TRUE;
|
||||
}
|
||||
|
||||
/* Open a text/plain sub-part if there is no sub-part open.
|
||||
*/
|
||||
if (!uty->open_subpart)
|
||||
{
|
||||
{
|
||||
// rhp: If we get here and we are being fed a line ending, we should
|
||||
// just eat it and continue and if we really get more data, we'll open
|
||||
// up the subpart then.
|
||||
@@ -198,48 +197,48 @@ MimeUntypedText_parse_line (const char *line, PRInt32 length, MimeObject *obj)
|
||||
if (line[0] == '\r') return 0;
|
||||
if (line[0] == '\n') return 0;
|
||||
|
||||
PR_ASSERT(!begin_line_p);
|
||||
status = MimeUntypedText_open_subpart (obj,
|
||||
MimeUntypedTextSubpartTypeText,
|
||||
TEXT_PLAIN, NULL, NULL, NULL);
|
||||
PR_ASSERT(uty->open_subpart);
|
||||
if (!uty->open_subpart) return -1;
|
||||
if (status < 0) return status;
|
||||
}
|
||||
PR_ASSERT(!begin_line_p);
|
||||
status = MimeUntypedText_open_subpart (obj,
|
||||
MimeUntypedTextSubpartTypeText,
|
||||
TEXT_PLAIN, NULL, NULL, NULL);
|
||||
PR_ASSERT(uty->open_subpart);
|
||||
if (!uty->open_subpart) return -1;
|
||||
if (status < 0) return status;
|
||||
}
|
||||
|
||||
/* Hand this line to the currently-open sub-part.
|
||||
*/
|
||||
status = uty->open_subpart->clazz->parse_buffer(line, length,
|
||||
uty->open_subpart);
|
||||
uty->open_subpart);
|
||||
if (status < 0) return status;
|
||||
|
||||
/* Close this sub-part if this line demands it.
|
||||
*/
|
||||
if (begin_line_p)
|
||||
;
|
||||
;
|
||||
else if (line[0] == 'e' &&
|
||||
uty->type == MimeUntypedTextSubpartTypeUUE &&
|
||||
MimeUntypedText_uu_end_line_p(line, length))
|
||||
{
|
||||
status = MimeUntypedText_close_subpart (obj);
|
||||
if (status < 0) return status;
|
||||
NS_ASSERTION(!uty->open_subpart, "no open subpart");
|
||||
}
|
||||
uty->type == MimeUntypedTextSubpartTypeUUE &&
|
||||
MimeUntypedText_uu_end_line_p(line, length))
|
||||
{
|
||||
status = MimeUntypedText_close_subpart (obj);
|
||||
if (status < 0) return status;
|
||||
NS_ASSERTION(!uty->open_subpart, "no open subpart");
|
||||
}
|
||||
else if (line[0] == '=' &&
|
||||
uty->type == MimeUntypedTextSubpartTypeYEnc &&
|
||||
MimeUntypedText_yenc_end_line_p(line, length))
|
||||
{
|
||||
status = MimeUntypedText_close_subpart (obj);
|
||||
if (status < 0) return status;
|
||||
NS_ASSERTION(!uty->open_subpart, "no open subpart");
|
||||
}
|
||||
uty->type == MimeUntypedTextSubpartTypeYEnc &&
|
||||
MimeUntypedText_yenc_end_line_p(line, length))
|
||||
{
|
||||
status = MimeUntypedText_close_subpart (obj);
|
||||
if (status < 0) return status;
|
||||
NS_ASSERTION(!uty->open_subpart, "no open subpart");
|
||||
}
|
||||
else if (uty->type == MimeUntypedTextSubpartTypeBinhex &&
|
||||
MimeUntypedText_binhex_end_line_p(line, length))
|
||||
{
|
||||
status = MimeUntypedText_close_subpart (obj);
|
||||
if (status < 0) return status;
|
||||
NS_ASSERTION(!uty->open_subpart, "no open subpart");
|
||||
}
|
||||
MimeUntypedText_binhex_end_line_p(line, length))
|
||||
{
|
||||
status = MimeUntypedText_close_subpart (obj);
|
||||
if (status < 0) return status;
|
||||
NS_ASSERTION(!uty->open_subpart, "no open subpart");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -252,26 +251,26 @@ MimeUntypedText_close_subpart (MimeObject *obj)
|
||||
int status;
|
||||
|
||||
if (uty->open_subpart)
|
||||
{
|
||||
status = uty->open_subpart->clazz->parse_eof(uty->open_subpart, PR_FALSE);
|
||||
uty->open_subpart = 0;
|
||||
{
|
||||
status = uty->open_subpart->clazz->parse_eof(uty->open_subpart, PR_FALSE);
|
||||
uty->open_subpart = 0;
|
||||
|
||||
PR_ASSERT(uty->open_hdrs);
|
||||
if (uty->open_hdrs)
|
||||
{
|
||||
MimeHeaders_free(uty->open_hdrs);
|
||||
uty->open_hdrs = 0;
|
||||
}
|
||||
uty->type = MimeUntypedTextSubpartTypeText;
|
||||
if (status < 0) return status;
|
||||
PR_ASSERT(uty->open_hdrs);
|
||||
if (uty->open_hdrs)
|
||||
{
|
||||
MimeHeaders_free(uty->open_hdrs);
|
||||
uty->open_hdrs = 0;
|
||||
}
|
||||
uty->type = MimeUntypedTextSubpartTypeText;
|
||||
if (status < 0) return status;
|
||||
|
||||
/* Never put out a separator between sub-parts of UntypedText.
|
||||
(This bypasses the rule that text/plain subparts always
|
||||
have separators before and after them.)
|
||||
*/
|
||||
if (obj->options && obj->options->state)
|
||||
obj->options->state->separator_suppressed_p = PR_TRUE;
|
||||
}
|
||||
/* Never put out a separator between sub-parts of UntypedText.
|
||||
(This bypasses the rule that text/plain subparts always
|
||||
have separators before and after them.)
|
||||
*/
|
||||
if (obj->options && obj->options->state)
|
||||
obj->options->state->separator_suppressed_p = PR_TRUE;
|
||||
}
|
||||
|
||||
PR_ASSERT(!uty->open_hdrs);
|
||||
return 0;
|
||||
@@ -279,52 +278,52 @@ MimeUntypedText_close_subpart (MimeObject *obj)
|
||||
|
||||
static int
|
||||
MimeUntypedText_open_subpart (MimeObject *obj,
|
||||
MimeUntypedTextSubpartType ttype,
|
||||
const char *type,
|
||||
const char *enc,
|
||||
const char *name,
|
||||
const char *desc)
|
||||
MimeUntypedTextSubpartType ttype,
|
||||
const char *type,
|
||||
const char *enc,
|
||||
const char *name,
|
||||
const char *desc)
|
||||
{
|
||||
MimeUntypedText *uty = (MimeUntypedText *) obj;
|
||||
int status = 0;
|
||||
char *h = 0;
|
||||
|
||||
if (!type || !*type || !nsCRT::strcasecmp(type, UNKNOWN_CONTENT_TYPE))
|
||||
type = APPLICATION_OCTET_STREAM;
|
||||
if (!type || !*type || !PL_strcasecmp(type, UNKNOWN_CONTENT_TYPE))
|
||||
type = APPLICATION_OCTET_STREAM;
|
||||
if (enc && !*enc)
|
||||
enc = 0;
|
||||
enc = 0;
|
||||
if (desc && !*desc)
|
||||
desc = 0;
|
||||
desc = 0;
|
||||
if (name && !*name)
|
||||
name = 0;
|
||||
name = 0;
|
||||
|
||||
if (uty->open_subpart)
|
||||
{
|
||||
status = MimeUntypedText_close_subpart (obj);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
{
|
||||
status = MimeUntypedText_close_subpart (obj);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
NS_ASSERTION(!uty->open_subpart, "no open subpart");
|
||||
NS_ASSERTION(!uty->open_hdrs, "no open headers");
|
||||
|
||||
/* To make one of these implicitly-typed sub-objects, we make up a fake
|
||||
header block, containing only the minimum number of MIME headers needed.
|
||||
We could do most of this (Type and Encoding) by making a null header
|
||||
block, and simply setting obj->content_type and obj->encoding; but making
|
||||
a fake header block is better for two reasons: first, it means that
|
||||
something will actually be displayed when in `Show All Headers' mode;
|
||||
and second, it's the only way to communicate the filename parameter,
|
||||
aside from adding a new slot to MimeObject (which is something to be
|
||||
avoided when possible.)
|
||||
header block, containing only the minimum number of MIME headers needed.
|
||||
We could do most of this (Type and Encoding) by making a null header
|
||||
block, and simply setting obj->content_type and obj->encoding; but making
|
||||
a fake header block is better for two reasons: first, it means that
|
||||
something will actually be displayed when in `Show All Headers' mode;
|
||||
and second, it's the only way to communicate the filename parameter,
|
||||
aside from adding a new slot to MimeObject (which is something to be
|
||||
avoided when possible.)
|
||||
*/
|
||||
|
||||
uty->open_hdrs = MimeHeaders_new();
|
||||
if (!uty->open_hdrs) return MIME_OUT_OF_MEMORY;
|
||||
|
||||
h = (char *) PR_MALLOC(strlen(type) +
|
||||
(enc ? strlen(enc) : 0) +
|
||||
(desc ? strlen(desc) : 0) +
|
||||
(name ? strlen(name) : 0) +
|
||||
100);
|
||||
(enc ? strlen(enc) : 0) +
|
||||
(desc ? strlen(desc) : 0) +
|
||||
(name ? strlen(name) : 0) +
|
||||
100);
|
||||
if (!h) return MIME_OUT_OF_MEMORY;
|
||||
|
||||
PL_strcpy(h, HEADER_CONTENT_TYPE ": ");
|
||||
@@ -334,30 +333,30 @@ MimeUntypedText_open_subpart (MimeObject *obj,
|
||||
if (status < 0) goto FAIL;
|
||||
|
||||
if (enc)
|
||||
{
|
||||
PL_strcpy(h, HEADER_CONTENT_TRANSFER_ENCODING ": ");
|
||||
PL_strcat(h, enc);
|
||||
PL_strcat(h, MSG_LINEBREAK);
|
||||
status = MimeHeaders_parse_line(h, strlen(h), uty->open_hdrs);
|
||||
if (status < 0) goto FAIL;
|
||||
}
|
||||
{
|
||||
PL_strcpy(h, HEADER_CONTENT_TRANSFER_ENCODING ": ");
|
||||
PL_strcat(h, enc);
|
||||
PL_strcat(h, MSG_LINEBREAK);
|
||||
status = MimeHeaders_parse_line(h, strlen(h), uty->open_hdrs);
|
||||
if (status < 0) goto FAIL;
|
||||
}
|
||||
|
||||
if (desc)
|
||||
{
|
||||
PL_strcpy(h, HEADER_CONTENT_DESCRIPTION ": ");
|
||||
PL_strcat(h, desc);
|
||||
PL_strcat(h, MSG_LINEBREAK);
|
||||
status = MimeHeaders_parse_line(h, strlen(h), uty->open_hdrs);
|
||||
if (status < 0) goto FAIL;
|
||||
}
|
||||
{
|
||||
PL_strcpy(h, HEADER_CONTENT_DESCRIPTION ": ");
|
||||
PL_strcat(h, desc);
|
||||
PL_strcat(h, MSG_LINEBREAK);
|
||||
status = MimeHeaders_parse_line(h, strlen(h), uty->open_hdrs);
|
||||
if (status < 0) goto FAIL;
|
||||
}
|
||||
if (name)
|
||||
{
|
||||
PL_strcpy(h, HEADER_CONTENT_DISPOSITION ": inline; filename=\"");
|
||||
PL_strcat(h, name);
|
||||
PL_strcat(h, "\"" MSG_LINEBREAK);
|
||||
status = MimeHeaders_parse_line(h, strlen(h), uty->open_hdrs);
|
||||
if (status < 0) goto FAIL;
|
||||
}
|
||||
{
|
||||
PL_strcpy(h, HEADER_CONTENT_DISPOSITION ": inline; filename=\"");
|
||||
PL_strcat(h, name);
|
||||
PL_strcat(h, "\"" MSG_LINEBREAK);
|
||||
status = MimeHeaders_parse_line(h, strlen(h), uty->open_hdrs);
|
||||
if (status < 0) goto FAIL;
|
||||
}
|
||||
|
||||
/* push out a blank line. */
|
||||
PL_strcpy(h, MSG_LINEBREAK);
|
||||
@@ -367,41 +366,41 @@ MimeUntypedText_open_subpart (MimeObject *obj,
|
||||
|
||||
/* Create a child... */
|
||||
{
|
||||
PRBool horrid_kludge = (obj->options && obj->options->state &&
|
||||
obj->options->state->first_part_written_p);
|
||||
if (horrid_kludge)
|
||||
obj->options->state->first_part_written_p = PR_FALSE;
|
||||
PRBool horrid_kludge = (obj->options && obj->options->state &&
|
||||
obj->options->state->first_part_written_p);
|
||||
if (horrid_kludge)
|
||||
obj->options->state->first_part_written_p = PR_FALSE;
|
||||
|
||||
uty->open_subpart = mime_create(type, uty->open_hdrs, obj->options);
|
||||
uty->open_subpart = mime_create(type, uty->open_hdrs, obj->options);
|
||||
|
||||
if (horrid_kludge)
|
||||
obj->options->state->first_part_written_p = PR_TRUE;
|
||||
if (horrid_kludge)
|
||||
obj->options->state->first_part_written_p = PR_TRUE;
|
||||
|
||||
if (!uty->open_subpart)
|
||||
{
|
||||
status = MIME_OUT_OF_MEMORY;
|
||||
goto FAIL;
|
||||
}
|
||||
if (!uty->open_subpart)
|
||||
{
|
||||
status = MIME_OUT_OF_MEMORY;
|
||||
goto FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Add it to the list... */
|
||||
status = ((MimeContainerClass *) obj->clazz)->add_child(obj,
|
||||
uty->open_subpart);
|
||||
uty->open_subpart);
|
||||
if (status < 0)
|
||||
{
|
||||
mime_free(uty->open_subpart);
|
||||
uty->open_subpart = 0;
|
||||
goto FAIL;
|
||||
}
|
||||
{
|
||||
mime_free(uty->open_subpart);
|
||||
uty->open_subpart = 0;
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
/* And start its parser going. */
|
||||
status = uty->open_subpart->clazz->parse_begin(uty->open_subpart);
|
||||
if (status < 0)
|
||||
{
|
||||
/* MimeContainer->finalize will take care of shutting it down now. */
|
||||
uty->open_subpart = 0;
|
||||
goto FAIL;
|
||||
}
|
||||
{
|
||||
/* MimeContainer->finalize will take care of shutting it down now. */
|
||||
uty->open_subpart = 0;
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
uty->type = ttype;
|
||||
|
||||
@@ -409,18 +408,18 @@ MimeUntypedText_open_subpart (MimeObject *obj,
|
||||
PR_FREEIF(h);
|
||||
|
||||
if (status < 0 && uty->open_hdrs)
|
||||
{
|
||||
MimeHeaders_free(uty->open_hdrs);
|
||||
uty->open_hdrs = 0;
|
||||
}
|
||||
{
|
||||
MimeHeaders_free(uty->open_hdrs);
|
||||
uty->open_hdrs = 0;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static PRBool
|
||||
MimeUntypedText_uu_begin_line_p(const char *line, PRInt32 length,
|
||||
MimeDisplayOptions *opt,
|
||||
char **type_ret, char **name_ret)
|
||||
MimeDisplayOptions *opt,
|
||||
char **type_ret, char **name_ret)
|
||||
{
|
||||
const char *s;
|
||||
char *name = 0;
|
||||
@@ -439,16 +438,16 @@ MimeUntypedText_uu_begin_line_p(const char *line, PRInt32 length,
|
||||
if (*s < '0' || *s > '7') return PR_FALSE;
|
||||
s++;
|
||||
if (*s == ' ')
|
||||
s++;
|
||||
s++;
|
||||
else
|
||||
{
|
||||
if (*s < '0' || *s > '7') return PR_FALSE;
|
||||
s++;
|
||||
if (*s != ' ') return PR_FALSE;
|
||||
}
|
||||
{
|
||||
if (*s < '0' || *s > '7') return PR_FALSE;
|
||||
s++;
|
||||
if (*s != ' ') return PR_FALSE;
|
||||
}
|
||||
|
||||
while (nsCRT::IsAsciiSpace(*s))
|
||||
s++;
|
||||
while (IS_SPACE(*s))
|
||||
s++;
|
||||
|
||||
name = (char *) PR_MALLOC(((line+length)-s) + 1);
|
||||
if (!name) return PR_FALSE; /* grr... */
|
||||
@@ -462,19 +461,19 @@ MimeUntypedText_uu_begin_line_p(const char *line, PRInt32 length,
|
||||
/* Now try and figure out a type.
|
||||
*/
|
||||
if (opt && opt->file_type_fn)
|
||||
type = opt->file_type_fn(name, opt->stream_closure);
|
||||
type = opt->file_type_fn(name, opt->stream_closure);
|
||||
else
|
||||
type = 0;
|
||||
type = 0;
|
||||
|
||||
if (name_ret)
|
||||
*name_ret = name;
|
||||
*name_ret = name;
|
||||
else
|
||||
PR_FREEIF(name);
|
||||
PR_FREEIF(name);
|
||||
|
||||
if (type_ret)
|
||||
*type_ret = type;
|
||||
*type_ret = type;
|
||||
else
|
||||
PR_FREEIF(type);
|
||||
PR_FREEIF(type);
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
@@ -485,36 +484,36 @@ MimeUntypedText_uu_end_line_p(const char *line, PRInt32 length)
|
||||
#if 0
|
||||
/* A strictly conforming uuencode end line. */
|
||||
return (line[0] == 'e' &&
|
||||
line[1] == 'n' &&
|
||||
line[2] == 'd' &&
|
||||
(line[3] == 0 || nsCRT::IsAsciiSpace(line[3])));
|
||||
line[1] == 'n' &&
|
||||
line[2] == 'd' &&
|
||||
(line[3] == 0 || IS_SPACE(line[3])));
|
||||
#else
|
||||
/* ...but, why don't we accept any line that begins with the three
|
||||
letters "END" in any case: I've seen lots of partial messages
|
||||
that look like
|
||||
letters "END" in any case: I've seen lots of partial messages
|
||||
that look like
|
||||
|
||||
BEGIN----- Cut Here-----
|
||||
begin 644 foo.gif
|
||||
Mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
END------- Cut Here-----
|
||||
BEGIN----- Cut Here-----
|
||||
begin 644 foo.gif
|
||||
Mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
END------- Cut Here-----
|
||||
|
||||
so let's be lenient here. (This is only for the untyped-text-plain
|
||||
case -- the uudecode parser itself is strict.)
|
||||
so let's be lenient here. (This is only for the untyped-text-plain
|
||||
case -- the uudecode parser itself is strict.)
|
||||
*/
|
||||
return (line[0] == ' ' ||
|
||||
line[0] == '\t' ||
|
||||
((line[0] == 'e' || line[0] == 'E') &&
|
||||
(line[1] == 'n' || line[1] == 'N') &&
|
||||
(line[2] == 'd' || line[2] == 'D')));
|
||||
line[0] == '\t' ||
|
||||
((line[0] == 'e' || line[0] == 'E') &&
|
||||
(line[1] == 'n' || line[1] == 'N') &&
|
||||
(line[2] == 'd' || line[2] == 'D')));
|
||||
#endif
|
||||
}
|
||||
|
||||
static PRBool
|
||||
MimeUntypedText_yenc_begin_line_p(const char *line, PRInt32 length,
|
||||
MimeDisplayOptions *opt,
|
||||
char **type_ret, char **name_ret)
|
||||
MimeDisplayOptions *opt,
|
||||
char **type_ret, char **name_ret)
|
||||
{
|
||||
const char *s;
|
||||
const char *endofline = line + length;
|
||||
@@ -535,7 +534,7 @@ MimeUntypedText_yenc_begin_line_p(const char *line, PRInt32 length,
|
||||
|
||||
/* ...next, look for <space>size= */
|
||||
if ((endofline - s) < 6 || strncmp (s, " size=", 6)) return PR_FALSE;
|
||||
|
||||
|
||||
/* ...then couple digits. */
|
||||
for (s += 6; s < endofline; s ++)
|
||||
if (*s < '0' || *s > '9')
|
||||
@@ -558,19 +557,19 @@ MimeUntypedText_yenc_begin_line_p(const char *line, PRInt32 length,
|
||||
/* Now try and figure out a type.
|
||||
*/
|
||||
if (opt && opt->file_type_fn)
|
||||
type = opt->file_type_fn(name, opt->stream_closure);
|
||||
type = opt->file_type_fn(name, opt->stream_closure);
|
||||
else
|
||||
type = 0;
|
||||
type = 0;
|
||||
|
||||
if (name_ret)
|
||||
*name_ret = name;
|
||||
*name_ret = name;
|
||||
else
|
||||
PR_FREEIF(name);
|
||||
PR_FREEIF(name);
|
||||
|
||||
if (type_ret)
|
||||
*type_ret = type;
|
||||
*type_ret = type;
|
||||
else
|
||||
PR_FREEIF(type);
|
||||
PR_FREEIF(type);
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
@@ -580,7 +579,7 @@ MimeUntypedText_yenc_end_line_p(const char *line, PRInt32 length)
|
||||
{
|
||||
if (length < 11 || strncmp (line, "=yend size=", 11)) return PR_FALSE;
|
||||
|
||||
return PR_TRUE;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -589,21 +588,21 @@ MimeUntypedText_yenc_end_line_p(const char *line, PRInt32 length)
|
||||
|
||||
static PRBool
|
||||
MimeUntypedText_binhex_begin_line_p(const char *line, PRInt32 length,
|
||||
MimeDisplayOptions *opt)
|
||||
MimeDisplayOptions *opt)
|
||||
{
|
||||
if (length <= BINHEX_MAGIC_LEN)
|
||||
return PR_FALSE;
|
||||
return PR_FALSE;
|
||||
|
||||
while(length > 0 && nsCRT::IsAsciiSpace(line[length-1]))
|
||||
length--;
|
||||
while(length > 0 && IS_SPACE(line[length-1]))
|
||||
length--;
|
||||
|
||||
if (length != BINHEX_MAGIC_LEN)
|
||||
return PR_FALSE;
|
||||
return PR_FALSE;
|
||||
|
||||
if (!strncmp(line, BINHEX_MAGIC, BINHEX_MAGIC_LEN))
|
||||
return PR_TRUE;
|
||||
return PR_TRUE;
|
||||
else
|
||||
return PR_FALSE;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
static PRBool
|
||||
@@ -613,7 +612,7 @@ MimeUntypedText_binhex_end_line_p(const char *line, PRInt32 length)
|
||||
if (length > 0 && line[length-1] == '\r') length--;
|
||||
|
||||
if (length != 0 && length != 64)
|
||||
return PR_TRUE;
|
||||
return PR_TRUE;
|
||||
else
|
||||
return PR_FALSE;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
@@ -39,11 +39,11 @@
|
||||
#include "msgCore.h" // precompiled header...
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsMsgHeaderParser.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "comi18n.h"
|
||||
#include "prmem.h"
|
||||
|
||||
nsresult FillResultsArray(const char * aName, const char *aAddress, PRUnichar ** aOutgoingEmailAddress, PRUnichar ** aOutgoingName,
|
||||
nsresult FillResultsArray(const char * aName, const char *aAddress, PRUnichar ** aOutgoingEmailAddress, PRUnichar ** aOutgoingName,
|
||||
PRUnichar ** aOutgoingFullName, nsIMsgHeaderParser *aParser);
|
||||
|
||||
/*
|
||||
@@ -58,7 +58,7 @@ nsresult FillResultsArray(const char * aName, const char *aAddress, PRUnichar **
|
||||
memcpy(_D,_S,_LEN); _D += _LEN; } } while (0)
|
||||
//#define NEXT_CHAR(_STR) (_STR = (* (char *) _STR < 128) ? (char *) _STR + 1 : NextChar_UTF8((char *)_STR))
|
||||
#define NEXT_CHAR(_STR) (_STR = NextChar_UTF8((char *)_STR))
|
||||
#define TRIM_WHITESPACE(_S,_E,_T) do { while (_E > _S && nsCRT::IsAsciiSpace(_E[-1])) _E--;\
|
||||
#define TRIM_WHITESPACE(_S,_E,_T) do { while (_E > _S && IS_SPACE(_E[-1])) _E--;\
|
||||
*_E++ = _T; } while (0)
|
||||
|
||||
/*
|
||||
@@ -98,7 +98,7 @@ nsMsgHeaderParser::~nsMsgHeaderParser()
|
||||
NS_IMPL_ISUPPORTS1(nsMsgHeaderParser, nsIMsgHeaderParser)
|
||||
|
||||
// helper function called by ParseHeadersWithArray
|
||||
nsresult FillResultsArray(const char * aName, const char *aAddress, PRUnichar ** aOutgoingEmailAddress, PRUnichar ** aOutgoingName,
|
||||
nsresult FillResultsArray(const char * aName, const char *aAddress, PRUnichar ** aOutgoingEmailAddress, PRUnichar ** aOutgoingName,
|
||||
PRUnichar ** aOutgoingFullName, nsIMsgHeaderParser *aParser)
|
||||
{
|
||||
NS_ENSURE_ARG(aParser);
|
||||
@@ -111,7 +111,7 @@ nsresult FillResultsArray(const char * aName, const char *aAddress, PRUnichar **
|
||||
*aOutgoingEmailAddress = ToNewUnicode(NS_ConvertUTF8toUTF16(result ? result : aAddress));
|
||||
PR_FREEIF(result);
|
||||
}
|
||||
|
||||
|
||||
if (aName)
|
||||
{
|
||||
result = MIME_DecodeMimeHeader(aName, NULL, PR_FALSE, PR_TRUE);
|
||||
@@ -151,7 +151,7 @@ NS_IMETHODIMP nsMsgHeaderParser::ParseHeadersWithArray(const PRUnichar * aLine,
|
||||
char * utf8String = ToNewUTF8String(tempString);
|
||||
|
||||
rv = ParseHeaderAddresses("UTF-8", utf8String, &names, &addresses, &numAddresses);
|
||||
nsCRT::free(utf8String);
|
||||
NS_Free(utf8String);
|
||||
if (NS_SUCCEEDED(rv) && numAddresses)
|
||||
{
|
||||
// allocate space for our arrays....
|
||||
@@ -165,7 +165,7 @@ NS_IMETHODIMP nsMsgHeaderParser::ParseHeadersWithArray(const PRUnichar * aLine,
|
||||
PRUnichar ** outgoingFullNames = *aFullNames;
|
||||
|
||||
// iterate over the results and fill in our arrays....
|
||||
PRUint32 index = 0;
|
||||
PRUint32 index = 0;
|
||||
const char * currentName = names;
|
||||
const char * currentAddress = addresses;
|
||||
char * unquotedName = nsnull;
|
||||
@@ -175,7 +175,7 @@ NS_IMETHODIMP nsMsgHeaderParser::ParseHeadersWithArray(const PRUnichar * aLine,
|
||||
rv = FillResultsArray(unquotedName, currentAddress, &outgoingEmailAddresses[index], &outgoingNames[index], &outgoingFullNames[index], this);
|
||||
else
|
||||
rv = FillResultsArray(currentName, currentAddress, &outgoingEmailAddresses[index], &outgoingNames[index], &outgoingFullNames[index], this);
|
||||
|
||||
|
||||
PR_FREEIF(unquotedName);
|
||||
currentName += strlen(currentName) + 1;
|
||||
currentAddress += strlen(currentAddress) + 1;
|
||||
@@ -255,7 +255,7 @@ nsresult nsMsgHeaderParser::RemoveDuplicateAddresses (const char *charset, const
|
||||
nsresult nsMsgHeaderParser::MakeFullAddress (const char *charset, const char* name, const char* addr, char ** fullAddress)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(fullAddress);
|
||||
|
||||
|
||||
*fullAddress = msg_make_full_address(name, addr);
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -263,7 +263,7 @@ nsresult nsMsgHeaderParser::MakeFullAddress (const char *charset, const char* na
|
||||
nsresult nsMsgHeaderParser::MakeFullAddressWString (const PRUnichar* name, const PRUnichar* addr, PRUnichar ** fullAddress)
|
||||
{
|
||||
nsCString utf8Str;
|
||||
nsresult rv = MakeFullAddress(nsnull, NS_ConvertUTF16toUTF8(name).get(),
|
||||
nsresult rv = MakeFullAddress(nsnull, NS_ConvertUTF16toUTF8(name).get(),
|
||||
NS_ConvertUTF16toUTF8(addr).get(), getter_Copies(utf8Str));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
@@ -313,7 +313,7 @@ nsresult nsMsgHeaderParser::ReformatUnquotedAddresses (const PRUnichar *line, PR
|
||||
char *writePtr = outputStr;
|
||||
const char *endOutputPtr = outputStr + outputMaxLen;
|
||||
const char *endPtr = readPtr + lineLen;
|
||||
|
||||
|
||||
const char *startRecipient = readPtr;
|
||||
char* reformated;
|
||||
PRBool openQuoteLevel1 = PR_FALSE;
|
||||
@@ -343,7 +343,7 @@ nsresult nsMsgHeaderParser::ReformatUnquotedAddresses (const PRUnichar *line, PR
|
||||
*/
|
||||
char * tempEnd = NS_CONST_CAST(char *, readPtr);
|
||||
*tempEnd = 0;
|
||||
|
||||
|
||||
reformated = msg_reformat_Header_addresses(startRecipient);
|
||||
if (reformated)
|
||||
{
|
||||
@@ -415,9 +415,9 @@ nsresult NS_NewHeaderParser(nsIMsgHeaderParser ** aInstancePtrResult)
|
||||
return NS_ERROR_NULL_POINTER; /* aInstancePtrResult was NULL....*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* The remainder of this file is the actual parsing code and it was extracted verbatim from addrutils.cpp
|
||||
* The remainder of this file is the actual parsing code and it was extracted verbatim from addrutils.cpp
|
||||
*/
|
||||
|
||||
/* msg_parse_Header_addresses
|
||||
@@ -478,10 +478,10 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad
|
||||
name_start = name_buf;
|
||||
addr_start = addr_buf;
|
||||
this_start = line;
|
||||
|
||||
|
||||
/* Skip over extra whitespace or commas before addresses.
|
||||
*/
|
||||
while (*line_end && (nsCRT::IsAsciiSpace(*line_end) || *line_end == ','))
|
||||
while (*line_end && (IS_SPACE(*line_end) || *line_end == ','))
|
||||
NEXT_CHAR(line_end);
|
||||
|
||||
while (*line_end)
|
||||
@@ -501,7 +501,7 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad
|
||||
if (!*line_end) /* otherwise, we walk off end of line, right? */
|
||||
break;
|
||||
}
|
||||
else if (*line_end == '\"')
|
||||
else if (*line_end == '\"')
|
||||
{
|
||||
int leave_quotes = 0;
|
||||
|
||||
@@ -572,18 +572,17 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad
|
||||
{
|
||||
const char *s = oparen + 1;
|
||||
|
||||
/* Copy the chars inside the parens onto the "name" buffer.
|
||||
*/
|
||||
/* Copy the chars inside the parens onto the "name" buffer. */
|
||||
|
||||
/* Push out some whitespace before the paren, if
|
||||
* there is non-whitespace there already.
|
||||
*/
|
||||
if (name_out > name_start && !nsCRT::IsAsciiSpace(name_out [-1]))
|
||||
* there is non-whitespace there already.
|
||||
*/
|
||||
if (name_out > name_start && !IS_SPACE(name_out [-1]))
|
||||
*name_out++ = ' ';
|
||||
|
||||
/* Skip leading whitespace.
|
||||
*/
|
||||
while (nsCRT::IsAsciiSpace(*s) && s < line_end)
|
||||
while (IS_SPACE(*s) && s < line_end)
|
||||
s++;
|
||||
|
||||
while (s < line_end)
|
||||
@@ -599,7 +598,7 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad
|
||||
if (*s == '\\') /* remove one \ */
|
||||
s++;
|
||||
|
||||
if (nsCRT::IsAsciiSpace(*s) && name_out > name_start && nsCRT::IsAsciiSpace(name_out[-1]))
|
||||
if (IS_SPACE(*s) && name_out > name_start && IS_SPACE(name_out[-1]))
|
||||
/* collapse consecutive whitespace */;
|
||||
else
|
||||
COPY_CHAR(name_out, s);
|
||||
@@ -619,8 +618,8 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad
|
||||
/* Eat whitespace at the beginning of the line,
|
||||
* and eat consecutive whitespace within the line.
|
||||
*/
|
||||
if ( nsCRT::IsAsciiSpace(*line_end)
|
||||
&& (addr_out == addr_start || nsCRT::IsAsciiSpace(addr_out[-1])))
|
||||
if (IS_SPACE(*line_end)
|
||||
&& (addr_out == addr_start || IS_SPACE(addr_out[-1])))
|
||||
/* skip it */;
|
||||
else
|
||||
COPY_CHAR(addr_out, line_end);
|
||||
@@ -630,7 +629,7 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad
|
||||
NEXT_CHAR(line_end);
|
||||
}
|
||||
|
||||
/* Now we have extracted a single address from the comma-separated
|
||||
/* Now we have extracted a single address from the comma-separated
|
||||
* list of addresses. The characters have been divided among the
|
||||
* various buffers: the parts inside parens have been placed in the
|
||||
* name_buf, and everything else has been placed in the addr_buf.
|
||||
@@ -659,7 +658,7 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad
|
||||
|
||||
/* Skip leading whitespace.
|
||||
*/
|
||||
while (nsCRT::IsAsciiSpace(*s) && s < mailbox_start)
|
||||
while (IS_SPACE(*s) && s < mailbox_start)
|
||||
s++;
|
||||
|
||||
/* Copy up to (not including) the <
|
||||
@@ -678,7 +677,7 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad
|
||||
*name_out++ = *s++;
|
||||
continue;
|
||||
}
|
||||
if (nsCRT::IsAsciiSpace(*s) && name_out > name_start && nsCRT::IsAsciiSpace(name_out[-1]))
|
||||
if (IS_SPACE(*s) && name_out > name_start && IS_SPACE(name_out[-1]))
|
||||
/* collapse consecutive whitespace */;
|
||||
else
|
||||
COPY_CHAR(name_out, s);
|
||||
@@ -693,7 +692,7 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad
|
||||
|
||||
/* Skip whitespace after >
|
||||
*/
|
||||
while (nsCRT::IsAsciiSpace(*s) && s < line_end)
|
||||
while (IS_SPACE(*s) && s < line_end)
|
||||
s++;
|
||||
|
||||
/* Copy from just after > to the end.
|
||||
@@ -712,7 +711,7 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad
|
||||
*name_out++ = *s++;
|
||||
continue;
|
||||
}
|
||||
if (nsCRT::IsAsciiSpace (*s) && name_out > name_start && nsCRT::IsAsciiSpace (name_out[-1]))
|
||||
if (IS_SPACE(*s) && name_out > name_start && IS_SPACE(name_out[-1]))
|
||||
/* collapse consecutive whitespace */;
|
||||
else
|
||||
COPY_CHAR(name_out, s);
|
||||
@@ -730,7 +729,7 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad
|
||||
|
||||
/* Skip leading whitespace.
|
||||
*/
|
||||
while (nsCRT::IsAsciiSpace(*s) && s < mailbox_end)
|
||||
while (IS_SPACE(*s) && s < mailbox_end)
|
||||
s++;
|
||||
|
||||
/* Copy up to (not including) the >
|
||||
@@ -774,7 +773,7 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad
|
||||
L = msg_quote_phrase_or_addr(name_start, L, PR_FALSE);
|
||||
name_out = name_start + L + 1;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (quote_addrs_p && addresses)
|
||||
{
|
||||
@@ -794,7 +793,7 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad
|
||||
NEXT_CHAR(line_end);
|
||||
|
||||
/* Skip over extra whitespace or commas between addresses. */
|
||||
while (*line_end && (nsCRT::IsAsciiSpace(*line_end) || *line_end == ','))
|
||||
while (*line_end && (IS_SPACE(*line_end) || *line_end == ','))
|
||||
line_end++;
|
||||
|
||||
this_start = line_end;
|
||||
@@ -808,10 +807,10 @@ static int msg_parse_Header_addresses (const char *line, char **names, char **ad
|
||||
{
|
||||
char *s;
|
||||
for (s = name_buf; s < name_out; NEXT_CHAR(s))
|
||||
if (nsCRT::IsAsciiSpace(*s) && *s != ' ')
|
||||
if (IS_SPACE(*s) && *s != ' ')
|
||||
*s = ' ';
|
||||
for (s = addr_buf; s < addr_out; NEXT_CHAR(s))
|
||||
if (nsCRT::IsAsciiSpace(*s) && *s != ' ')
|
||||
if (IS_SPACE(*s) && *s != ' ')
|
||||
*s = ' ';
|
||||
}
|
||||
|
||||
@@ -862,7 +861,7 @@ msg_quote_phrase_or_addr(char *address, PRInt32 length, PRBool addr_p)
|
||||
address = in;
|
||||
break;
|
||||
}
|
||||
else if (!nsCRT::IsAsciiDigit(*in) && !nsCRT::IsAsciiAlpha(*in) && *in != '@' && *in != '.')
|
||||
else if (!IS_DIGIT(*in) && !IS_ALPHA(*in) && *in != '@' && *in != '.')
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -904,7 +903,7 @@ msg_quote_phrase_or_addr(char *address, PRInt32 length, PRBool addr_p)
|
||||
|
||||
else if ( /* *in >= 127 || *in < 0 ducarroz: 8bits characters will be mime encoded therefore they are not a problem
|
||||
||*/ (*in == ';' && !addr_p) || *in == '$' || *in == '(' || *in == ')'
|
||||
|| *in == '<' || *in == '>' || *in == '@' || *in == ',')
|
||||
|| *in == '<' || *in == '>' || *in == '@' || *in == ',')
|
||||
/* If the name contains control chars or Header specials, it needs to
|
||||
* be enclosed in quotes. Double-quotes and backslashes will be dealt
|
||||
* with separately.
|
||||
@@ -1032,7 +1031,7 @@ msg_unquote_phrase_or_addr(const char *line, PRBool preserveIntegrity, char **li
|
||||
*/
|
||||
if (*line != '\"')
|
||||
{
|
||||
*lineout = nsCRT::strdup(line);
|
||||
*lineout = strdup(line);
|
||||
if (!*lineout)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
else
|
||||
@@ -1072,7 +1071,7 @@ msg_unquote_phrase_or_addr(const char *line, PRBool preserveIntegrity, char **li
|
||||
|
||||
if (comma && at_sign)
|
||||
{
|
||||
*lineout = nsCRT::strdup(line);
|
||||
*lineout = strdup(line);
|
||||
if (!*lineout)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
else
|
||||
@@ -1082,11 +1081,11 @@ msg_unquote_phrase_or_addr(const char *line, PRBool preserveIntegrity, char **li
|
||||
|
||||
/* Don't copy the first double quote
|
||||
*/
|
||||
*lineout = nsCRT::strdup(line + 1);
|
||||
*lineout = strdup(line + 1);
|
||||
if (!*lineout)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
const char *lineptr = line + 1;
|
||||
const char *lineptr = line + 1;
|
||||
char *outptr = *lineout;
|
||||
PRBool escaped = PR_FALSE;
|
||||
|
||||
@@ -1111,7 +1110,7 @@ msg_unquote_phrase_or_addr(const char *line, PRBool preserveIntegrity, char **li
|
||||
}
|
||||
}
|
||||
*outptr = '\0';
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -1242,7 +1241,7 @@ msg_extract_Header_address_names(const char *line)
|
||||
/* msg_extract_Header_address_name
|
||||
*
|
||||
* Like MSG_ExtractHeaderAddressNames(), but only returns the first name
|
||||
* in the list, if there is more than one.
|
||||
* in the list, if there is more than one.
|
||||
*/
|
||||
static char *
|
||||
msg_extract_Header_address_name(const char *line)
|
||||
@@ -1296,7 +1295,7 @@ msg_format_Header_addresses (const char *names, const char *addrs,
|
||||
len2 = strlen(s2);
|
||||
s1 += len1 + 1;
|
||||
s2 += len2 + 1;
|
||||
|
||||
|
||||
len1 = (len1 * 2) + 2; //(N*2) + 2 in case we need to quote it
|
||||
len2 = (len2 * 2) + 2;
|
||||
name_maxlen = PR_MAX(name_maxlen, len1);
|
||||
@@ -1322,7 +1321,7 @@ msg_format_Header_addresses (const char *names, const char *addrs,
|
||||
for (i = 0; (int)i < count; i++)
|
||||
{
|
||||
char *o;
|
||||
|
||||
|
||||
PL_strncpy(aName, s1, name_maxlen);
|
||||
PL_strncpy(anAddr, s2, addr_maxlen);
|
||||
len1 = msg_quote_phrase_or_addr(aName, strlen(s1), PR_FALSE);
|
||||
@@ -1364,10 +1363,10 @@ msg_format_Header_addresses (const char *names, const char *addrs,
|
||||
column += (out - o);
|
||||
}
|
||||
*out = 0;
|
||||
|
||||
|
||||
PR_FREEIF(aName);
|
||||
PR_FREEIF(anAddr);
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1429,7 +1428,7 @@ msg_remove_duplicate_addresses(const char *addrs, const char *other_addrs,
|
||||
if (count1 < 0) goto FAIL;
|
||||
if (count1 == 0)
|
||||
{
|
||||
result = nsCRT::strdup("");
|
||||
result = strdup("");
|
||||
goto FAIL;
|
||||
}
|
||||
if (other_addrs)
|
||||
@@ -1501,7 +1500,7 @@ msg_remove_duplicate_addresses(const char *addrs, const char *other_addrs,
|
||||
{
|
||||
PRBool found = PR_FALSE;
|
||||
for (j = 0; j < count2; j++)
|
||||
if (!nsCRT::strcasecmp (a_array1[i], a_array2[j]))
|
||||
if (!PL_strcasecmp (a_array1[i], a_array2[j]))
|
||||
{
|
||||
found = PR_TRUE;
|
||||
break;
|
||||
@@ -1509,7 +1508,7 @@ msg_remove_duplicate_addresses(const char *addrs, const char *other_addrs,
|
||||
|
||||
if (!found)
|
||||
for (j = 0; j < count3; j++)
|
||||
if (!nsCRT::strcasecmp(a_array1[i], a_array3[j]))
|
||||
if (!PL_strcasecmp(a_array1[i], a_array3[j]))
|
||||
{
|
||||
found = PR_TRUE;
|
||||
break;
|
||||
|
||||
@@ -58,11 +58,10 @@ class nsMsgHeaderParser: public nsIMsgHeaderParser
|
||||
{
|
||||
public:
|
||||
nsMsgHeaderParser();
|
||||
virtual ~nsMsgHeaderParser();
|
||||
|
||||
/* this macro defines QueryInterface, AddRef and Release for this class */
|
||||
NS_DECL_ISUPPORTS
|
||||
virtual ~nsMsgHeaderParser();
|
||||
|
||||
/* this macro defines QueryInterface, AddRef and Release for this class */
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMSGHEADERPARSER
|
||||
};
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
#include "nsString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsCategoryManagerUtils.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsISimpleMimeConverter.h"
|
||||
|
||||
@@ -238,7 +238,7 @@ bridge_new_new_uri(void *bridgeStream, nsIURI *aURI, PRInt32 aOutputType)
|
||||
{
|
||||
if (!urlString.IsEmpty())
|
||||
{
|
||||
CRTFREEIF(*url_name);
|
||||
NS_Free(*url_name);
|
||||
*url_name = ToNewCString(urlString);
|
||||
if (!(*url_name))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
@@ -712,14 +712,12 @@ NS_IMETHODIMP nsStreamConverter::GetContentType(char **aOutputContentType)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// since this method passes a string through an IDL file we need to use nsMemory to allocate it
|
||||
// and not nsCRT::strdup!
|
||||
// and not strdup!
|
||||
// (1) check to see if we have a real content type...use it first...
|
||||
if (!mRealContentType.IsEmpty())
|
||||
*aOutputContentType = ToNewCString(mRealContentType);
|
||||
else if (mOutputFormat.LowerCaseEqualsLiteral("raw"))
|
||||
{
|
||||
*aOutputContentType = (char *) nsMemory::Clone(UNKNOWN_CONTENT_TYPE, sizeof(UNKNOWN_CONTENT_TYPE));
|
||||
}
|
||||
else
|
||||
*aOutputContentType = ToNewCString(mOutputFormat);
|
||||
return NS_OK;
|
||||
|
||||
Reference in New Issue
Block a user