mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
fix 204350, handling of message/rfc822 attachments opened in standalone msg window, sr=mscott
This commit is contained in:
parent
ed89039ff1
commit
fc1f4f0336
@ -617,6 +617,7 @@ nsMessenger::LoadURL(nsIDOMWindowInternal *aWin, const char *aURL)
|
|||||||
NS_ENSURE_TRUE(!uriString.IsEmpty(), NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(!uriString.IsEmpty(), NS_ERROR_FAILURE);
|
||||||
|
|
||||||
PRBool loadingFromFile = PR_FALSE;
|
PRBool loadingFromFile = PR_FALSE;
|
||||||
|
PRBool getDummyMsgHdr = PR_FALSE;
|
||||||
PRInt64 fileSize;
|
PRInt64 fileSize;
|
||||||
|
|
||||||
if (StringBeginsWith(uriString, NS_LITERAL_STRING("file:")))
|
if (StringBeginsWith(uriString, NS_LITERAL_STRING("file:")))
|
||||||
@ -634,7 +635,10 @@ nsMessenger::LoadURL(nsIDOMWindowInternal *aWin, const char *aURL)
|
|||||||
uriString.ReplaceSubstring(NS_LITERAL_STRING("file:"), NS_LITERAL_STRING("mailbox:"));
|
uriString.ReplaceSubstring(NS_LITERAL_STRING("file:"), NS_LITERAL_STRING("mailbox:"));
|
||||||
uriString.Append(NS_LITERAL_STRING("&number=0"));
|
uriString.Append(NS_LITERAL_STRING("&number=0"));
|
||||||
loadingFromFile = PR_TRUE;
|
loadingFromFile = PR_TRUE;
|
||||||
|
getDummyMsgHdr = PR_TRUE;
|
||||||
}
|
}
|
||||||
|
else if (FindInReadable(NS_LITERAL_STRING("type=application/x-message-display"), uriString))
|
||||||
|
getDummyMsgHdr = PR_TRUE;
|
||||||
|
|
||||||
nsCOMPtr<nsIURI> uri;
|
nsCOMPtr<nsIURI> uri;
|
||||||
rv = NS_NewURI(getter_AddRefs(uri), uriString);
|
rv = NS_NewURI(getter_AddRefs(uri), uriString);
|
||||||
@ -645,21 +649,25 @@ nsMessenger::LoadURL(nsIDOMWindowInternal *aWin, const char *aURL)
|
|||||||
if (msgurl)
|
if (msgurl)
|
||||||
{
|
{
|
||||||
msgurl->SetMsgWindow(mMsgWindow);
|
msgurl->SetMsgWindow(mMsgWindow);
|
||||||
if (loadingFromFile)
|
if (loadingFromFile || getDummyMsgHdr)
|
||||||
{
|
{
|
||||||
nsCOMPtr <nsIMailboxUrl> mailboxUrl = do_QueryInterface(msgurl, &rv);
|
if (loadingFromFile)
|
||||||
mailboxUrl->SetMessageSize((PRUint32) fileSize);
|
|
||||||
nsCOMPtr <nsIMsgHeaderSink> headerSink;
|
|
||||||
// need to tell the header sink to capture some headers to create a fake db header
|
|
||||||
// so we can do reply to a .eml file or a rfc822 msg attachment.
|
|
||||||
mMsgWindow->GetMsgHeaderSink(getter_AddRefs(headerSink));
|
|
||||||
if (headerSink)
|
|
||||||
{
|
{
|
||||||
nsCOMPtr <nsIMsgDBHdr> dummyHeader;
|
nsCOMPtr <nsIMailboxUrl> mailboxUrl = do_QueryInterface(msgurl, &rv);
|
||||||
headerSink->GetDummyMsgHeader(getter_AddRefs(dummyHeader));
|
mailboxUrl->SetMessageSize((PRUint32) fileSize);
|
||||||
if (dummyHeader)
|
}
|
||||||
|
if (getDummyMsgHdr)
|
||||||
|
{
|
||||||
|
nsCOMPtr <nsIMsgHeaderSink> headerSink;
|
||||||
|
// need to tell the header sink to capture some headers to create a fake db header
|
||||||
|
// so we can do reply to a .eml file or a rfc822 msg attachment.
|
||||||
|
mMsgWindow->GetMsgHeaderSink(getter_AddRefs(headerSink));
|
||||||
|
if (headerSink)
|
||||||
{
|
{
|
||||||
dummyHeader->SetMessageSize((PRUint32) fileSize);
|
nsCOMPtr <nsIMsgDBHdr> dummyHeader;
|
||||||
|
headerSink->GetDummyMsgHeader(getter_AddRefs(dummyHeader));
|
||||||
|
if (dummyHeader && loadingFromFile)
|
||||||
|
dummyHeader->SetMessageSize((PRUint32) fileSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -805,7 +813,7 @@ nsMessenger::OpenAttachment(const char * aContentType, const char * aURL, const
|
|||||||
rv = messageService->OpenAttachment(aContentType, aDisplayName, aURL, aMessageUri, mDocShell, mMsgWindow, nsnull);
|
rv = messageService->OpenAttachment(aContentType, aDisplayName, aURL, aMessageUri, mDocShell, mMsgWindow, nsnull);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
@ -1391,7 +1399,7 @@ nsMessenger::MsgHdrFromURI(const char *aUri, nsIMsgDBHdr **aMsgHdr)
|
|||||||
nsCOMPtr <nsIMsgMessageService> msgService;
|
nsCOMPtr <nsIMsgMessageService> msgService;
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
if (!strncmp(aUri, "file:", 5))
|
if (!strncmp(aUri, "file:", 5) || PL_strstr(aUri, "type=application/x-message-display"))
|
||||||
{
|
{
|
||||||
nsCOMPtr <nsIMsgHeaderSink> headerSink;
|
nsCOMPtr <nsIMsgHeaderSink> headerSink;
|
||||||
mMsgWindow->GetMsgHeaderSink(getter_AddRefs(headerSink));
|
mMsgWindow->GetMsgHeaderSink(getter_AddRefs(headerSink));
|
||||||
|
@ -979,7 +979,8 @@ NS_IMETHODIMP nsMsgDBView::ReloadMessageWithAllParts()
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
nsCAutoString forceAllParts(m_currentlyDisplayedMsgUri);
|
nsCAutoString forceAllParts(m_currentlyDisplayedMsgUri);
|
||||||
forceAllParts.AppendLiteral("?fetchCompleteMessage=true");
|
forceAllParts += (forceAllParts.FindChar('?') == kNotFound) ? "?" : "&";
|
||||||
|
forceAllParts.AppendLiteral("fetchCompleteMessage=true");
|
||||||
return mMessengerInstance->OpenURL(forceAllParts.get());
|
return mMessengerInstance->OpenURL(forceAllParts.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2950,9 +2951,9 @@ nsMsgDBView::DetermineActionsForJunkMsgs(PRBool* movingJunkMessages, PRBool* mar
|
|||||||
// only to automatically-classified messages.
|
// only to automatically-classified messages.
|
||||||
// Note that this behaviour should match the one in the front end for marking
|
// Note that this behaviour should match the one in the front end for marking
|
||||||
// as junk via toolbar/context menu.
|
// as junk via toolbar/context menu.
|
||||||
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||||
if (NS_SUCCEEDED(rv))
|
if (NS_SUCCEEDED(rv))
|
||||||
{
|
{
|
||||||
prefBranch->GetBoolPref("mailnews.ui.junk.manualMarkAsJunkMarksRead",
|
prefBranch->GetBoolPref("mailnews.ui.junk.manualMarkAsJunkMarksRead",
|
||||||
markingJunkMessagesRead);
|
markingJunkMessagesRead);
|
||||||
}
|
}
|
||||||
|
@ -100,6 +100,7 @@
|
|||||||
#include "nsImapProtocol.h"
|
#include "nsImapProtocol.h"
|
||||||
#include "nsIMsgMailSession.h"
|
#include "nsIMsgMailSession.h"
|
||||||
#include "nsIStreamConverterService.h"
|
#include "nsIStreamConverterService.h"
|
||||||
|
#include "nsNetUtil.h"
|
||||||
#include "nsInt64.h"
|
#include "nsInt64.h"
|
||||||
|
|
||||||
#define PREF_MAIL_ROOT_IMAP "mail.root.imap" // old - for backward compatibility only
|
#define PREF_MAIL_ROOT_IMAP "mail.root.imap" // old - for backward compatibility only
|
||||||
@ -313,6 +314,10 @@ NS_IMETHODIMP nsImapService::GetUrlForUri(const char *aMessageURI, nsIURI **aURL
|
|||||||
{
|
{
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
|
if (PL_strstr(aMessageURI, "&type=application/x-message-display"))
|
||||||
|
return NS_NewURI(aURL, aMessageURI);
|
||||||
|
|
||||||
|
|
||||||
nsCOMPtr<nsIMsgFolder> folder;
|
nsCOMPtr<nsIMsgFolder> folder;
|
||||||
nsXPIDLCString msgKey;
|
nsXPIDLCString msgKey;
|
||||||
rv = DecomposeImapURI(aMessageURI, getter_AddRefs(folder), getter_Copies(msgKey));
|
rv = DecomposeImapURI(aMessageURI, getter_AddRefs(folder), getter_Copies(msgKey));
|
||||||
@ -482,7 +487,37 @@ NS_IMETHODIMP nsImapService::DisplayMessage(const char* aMessageURI,
|
|||||||
nsXPIDLCString mimePart;
|
nsXPIDLCString mimePart;
|
||||||
nsCAutoString folderURI;
|
nsCAutoString folderURI;
|
||||||
nsMsgKey key;
|
nsMsgKey key;
|
||||||
|
nsCAutoString messageURI(aMessageURI);
|
||||||
|
|
||||||
|
PRInt32 typeIndex = messageURI.Find("&type=application/x-message-display");
|
||||||
|
if (typeIndex != kNotFound)
|
||||||
|
{
|
||||||
|
// This happens with forward inline of a message/rfc822 attachment opened in
|
||||||
|
// a standalone msg window.
|
||||||
|
// So, just cut to the chase and call AsyncOpen on a channel.
|
||||||
|
nsCOMPtr <nsIURI> uri;
|
||||||
|
messageURI.Cut(typeIndex, sizeof("&type=application/x-message-display") - 1);
|
||||||
|
rv = NS_NewURI(getter_AddRefs(uri), messageURI.get());
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
if (aURL)
|
||||||
|
NS_IF_ADDREF(*aURL = uri);
|
||||||
|
nsCOMPtr<nsIStreamListener> aStreamListener = do_QueryInterface(aDisplayConsumer, &rv);
|
||||||
|
if (NS_SUCCEEDED(rv) && aStreamListener)
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsIChannel> aChannel;
|
||||||
|
nsCOMPtr<nsILoadGroup> aLoadGroup;
|
||||||
|
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(uri, &rv);
|
||||||
|
if (NS_SUCCEEDED(rv) && mailnewsUrl)
|
||||||
|
mailnewsUrl->GetLoadGroup(getter_AddRefs(aLoadGroup));
|
||||||
|
|
||||||
|
rv = NewChannel(uri, getter_AddRefs(aChannel));
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
nsCOMPtr<nsISupports> aCtxt = do_QueryInterface(uri);
|
||||||
|
// now try to open the channel passing in our display consumer as the listener
|
||||||
|
return aChannel->AsyncOpen(aStreamListener, aCtxt);
|
||||||
|
}
|
||||||
|
}
|
||||||
rv = DecomposeImapURI(aMessageURI, getter_AddRefs(folder), getter_Copies(msgKey));
|
rv = DecomposeImapURI(aMessageURI, getter_AddRefs(folder), getter_Copies(msgKey));
|
||||||
if (msgKey.IsEmpty())
|
if (msgKey.IsEmpty())
|
||||||
return NS_MSG_MESSAGE_NOT_FOUND;
|
return NS_MSG_MESSAGE_NOT_FOUND;
|
||||||
|
@ -461,6 +461,8 @@ nsresult nsMailboxProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
|
|||||||
|
|
||||||
PRBool convertData = PR_FALSE;
|
PRBool convertData = PR_FALSE;
|
||||||
|
|
||||||
|
// need to check if we're fetching an rfc822 part in order to
|
||||||
|
// quote a message.
|
||||||
if (m_mailboxAction == nsIMailboxUrl::ActionFetchMessage)
|
if (m_mailboxAction == nsIMailboxUrl::ActionFetchMessage)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIMsgMailNewsUrl> msgUrl = do_QueryInterface(m_runningUrl, &rv);
|
nsCOMPtr<nsIMsgMailNewsUrl> msgUrl = do_QueryInterface(m_runningUrl, &rv);
|
||||||
|
@ -182,6 +182,9 @@ nsresult nsMailboxService::FetchMessage(const char* aMessageURI,
|
|||||||
nsMailboxAction actionToUse = mailboxAction;
|
nsMailboxAction actionToUse = mailboxAction;
|
||||||
|
|
||||||
nsCOMPtr <nsIURI> url;
|
nsCOMPtr <nsIURI> url;
|
||||||
|
|
||||||
|
nsCAutoString uriString(aMessageURI);
|
||||||
|
|
||||||
if (!strncmp(aMessageURI, "file:", 5))
|
if (!strncmp(aMessageURI, "file:", 5))
|
||||||
{
|
{
|
||||||
PRInt64 fileSize;
|
PRInt64 fileSize;
|
||||||
@ -221,7 +224,18 @@ nsresult nsMailboxService::FetchMessage(const char* aMessageURI,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rv = PrepareMessageUrl(aMessageURI, aUrlListener, actionToUse , getter_AddRefs(mailboxurl), aMsgWindow);
|
|
||||||
|
// this happens with forward inline of message/rfc822 attachment
|
||||||
|
// opened in a stand-alone msg window.
|
||||||
|
PRInt32 typeIndex = typeIndex = uriString.Find("&type=application/x-message-display");
|
||||||
|
if (typeIndex != kNotFound)
|
||||||
|
{
|
||||||
|
uriString.Cut(typeIndex, sizeof("&type=application/x-message-display") - 1);
|
||||||
|
rv = NS_NewURI(getter_AddRefs(url), uriString.get());
|
||||||
|
mailboxurl = do_QueryInterface(url);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
rv = PrepareMessageUrl(aMessageURI, aUrlListener, actionToUse , getter_AddRefs(mailboxurl), aMsgWindow);
|
||||||
|
|
||||||
if (NS_SUCCEEDED(rv))
|
if (NS_SUCCEEDED(rv))
|
||||||
{
|
{
|
||||||
@ -318,17 +332,6 @@ NS_IMETHODIMP nsMailboxService::OpenAttachment(const char *aContentType,
|
|||||||
{
|
{
|
||||||
nsCOMPtr <nsIURI> URL;
|
nsCOMPtr <nsIURI> URL;
|
||||||
nsCAutoString urlString(aUrl);
|
nsCAutoString urlString(aUrl);
|
||||||
// strip out ?type=application/x-message-display because it confuses libmime
|
|
||||||
|
|
||||||
PRInt32 typeIndex = urlString.Find("?type=application/x-message-display");
|
|
||||||
if (typeIndex != kNotFound)
|
|
||||||
{
|
|
||||||
urlString.Cut(typeIndex, sizeof("?type=application/x-message-display") - 1);
|
|
||||||
// we also need to replace the next '&' with '?'
|
|
||||||
PRInt32 firstPartIndex = urlString.FindChar('&');
|
|
||||||
if (firstPartIndex != kNotFound)
|
|
||||||
urlString.SetCharAt('?', firstPartIndex);
|
|
||||||
}
|
|
||||||
urlString += "&type=";
|
urlString += "&type=";
|
||||||
urlString += aContentType;
|
urlString += aContentType;
|
||||||
urlString += "&filename=";
|
urlString += "&filename=";
|
||||||
@ -389,7 +392,8 @@ nsMailboxService::SaveMessageToDisk(const char *aMessageURI,
|
|||||||
|
|
||||||
NS_IMETHODIMP nsMailboxService::GetUrlForUri(const char *aMessageURI, nsIURI **aURL, nsIMsgWindow *aMsgWindow)
|
NS_IMETHODIMP nsMailboxService::GetUrlForUri(const char *aMessageURI, nsIURI **aURL, nsIMsgWindow *aMsgWindow)
|
||||||
{
|
{
|
||||||
if (!strncmp(aMessageURI, "file:", 5))
|
if (!strncmp(aMessageURI, "file:", 5) || PL_strstr(aMessageURI, "type=application/x-message-display")
|
||||||
|
|| !strncmp(aMessageURI, "mailbox:", 8))
|
||||||
return NS_NewURI(aURL, aMessageURI);
|
return NS_NewURI(aURL, aMessageURI);
|
||||||
|
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
@ -2082,6 +2082,10 @@ mime_bridge_create_draft_stream(
|
|||||||
|
|
||||||
if (NS_SUCCEEDED(aURL->GetSpec(urlString)))
|
if (NS_SUCCEEDED(aURL->GetSpec(urlString)))
|
||||||
{
|
{
|
||||||
|
PRInt32 typeIndex = urlString.Find("&type=application/x-message-display");
|
||||||
|
if (typeIndex != kNotFound)
|
||||||
|
urlString.Cut(typeIndex, sizeof("&type=application/x-message-display") - 1);
|
||||||
|
|
||||||
mdd->url_name = ToNewCString(urlString);
|
mdd->url_name = ToNewCString(urlString);
|
||||||
if (!(mdd->url_name))
|
if (!(mdd->url_name))
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
|
@ -1372,6 +1372,16 @@ mime_set_url_part(const char *url, const char *part, PRBool append_p)
|
|||||||
|
|
||||||
if (!url || !part) return 0;
|
if (!url || !part) return 0;
|
||||||
|
|
||||||
|
nsCAutoString urlString(url);
|
||||||
|
PRInt32 typeIndex = urlString.Find("?type=application/x-message-display");
|
||||||
|
if (typeIndex != kNotFound)
|
||||||
|
{
|
||||||
|
urlString.Cut(typeIndex, sizeof("?type=application/x-message-display") - 1);
|
||||||
|
if (urlString.CharAt(typeIndex) == '&')
|
||||||
|
urlString.SetCharAt('?', typeIndex);
|
||||||
|
url = urlString.get();
|
||||||
|
}
|
||||||
|
|
||||||
for (s = url; *s; s++)
|
for (s = url; *s; s++)
|
||||||
{
|
{
|
||||||
if (*s == '?')
|
if (*s == '?')
|
||||||
@ -1389,7 +1399,7 @@ mime_set_url_part(const char *url, const char *part, PRBool append_p)
|
|||||||
;
|
;
|
||||||
part_end = s;
|
part_end = s;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = (char *) PR_MALLOC(strlen(url) + strlen(part) + 10);
|
result = (char *) PR_MALLOC(strlen(url) + strlen(part) + 10);
|
||||||
@ -1633,26 +1643,26 @@ mime_parse_url_options(const char *url, MimeDisplayOptions *options)
|
|||||||
{
|
{
|
||||||
const char *q;
|
const char *q;
|
||||||
MimeHeadersState default_headers = options->headers;
|
MimeHeadersState default_headers = options->headers;
|
||||||
|
|
||||||
if (!url || !*url) return 0;
|
if (!url || !*url) return 0;
|
||||||
if (!options) return 0;
|
if (!options) return 0;
|
||||||
|
|
||||||
q = PL_strrchr (url, '?');
|
q = PL_strrchr (url, '?');
|
||||||
if (! q) return 0;
|
if (! q) return 0;
|
||||||
q++;
|
q++;
|
||||||
while (*q)
|
while (*q)
|
||||||
{
|
{
|
||||||
const char *end, *value, *name_end;
|
const char *end, *value, *name_end;
|
||||||
for (end = q; *end && *end != '&'; end++)
|
for (end = q; *end && *end != '&'; end++)
|
||||||
;
|
;
|
||||||
for (value = q; *value != '=' && value < end; value++)
|
for (value = q; *value != '=' && value < end; value++)
|
||||||
;
|
;
|
||||||
name_end = value;
|
name_end = value;
|
||||||
if (value < end) value++;
|
if (value < end) value++;
|
||||||
if (name_end <= q)
|
if (name_end <= q)
|
||||||
;
|
;
|
||||||
else if (!nsCRT::strncasecmp ("headers", q, name_end - q))
|
else if (!nsCRT::strncasecmp ("headers", q, name_end - q))
|
||||||
{
|
{
|
||||||
if (end > value && !nsCRT::strncasecmp ("only", value, end-value))
|
if (end > value && !nsCRT::strncasecmp ("only", value, end-value))
|
||||||
options->headers = MimeHeadersOnly;
|
options->headers = MimeHeadersOnly;
|
||||||
else if (end > value && !nsCRT::strncasecmp ("none", value, end-value))
|
else if (end > value && !nsCRT::strncasecmp ("none", value, end-value))
|
||||||
@ -1669,117 +1679,115 @@ mime_parse_url_options(const char *url, MimeDisplayOptions *options)
|
|||||||
options->headers = MimeHeadersCitation;
|
options->headers = MimeHeadersCitation;
|
||||||
else
|
else
|
||||||
options->headers = default_headers;
|
options->headers = default_headers;
|
||||||
}
|
}
|
||||||
else if (!nsCRT::strncasecmp ("part", q, name_end - q))
|
else if (!nsCRT::strncasecmp ("part", q, name_end - q) &&
|
||||||
{
|
options->format_out != nsMimeOutput::nsMimeMessageBodyQuoting)
|
||||||
PR_FREEIF (options->part_to_load);
|
{
|
||||||
if (end > value)
|
PR_FREEIF (options->part_to_load);
|
||||||
{
|
if (end > value)
|
||||||
options->part_to_load = (char *) PR_MALLOC(end - value + 1);
|
{
|
||||||
if (!options->part_to_load)
|
options->part_to_load = (char *) PR_MALLOC(end - value + 1);
|
||||||
return MIME_OUT_OF_MEMORY;
|
if (!options->part_to_load)
|
||||||
memcpy(options->part_to_load, value, end-value);
|
return MIME_OUT_OF_MEMORY;
|
||||||
options->part_to_load[end-value] = 0;
|
memcpy(options->part_to_load, value, end-value);
|
||||||
}
|
options->part_to_load[end-value] = 0;
|
||||||
}
|
}
|
||||||
else if (!nsCRT::strncasecmp ("rot13", q, name_end - q))
|
}
|
||||||
{
|
else if (!nsCRT::strncasecmp ("rot13", q, name_end - q))
|
||||||
if (end <= value || !nsCRT::strncasecmp ("true", value, end - value))
|
{
|
||||||
options->rot13_p = PR_TRUE;
|
options->rot13_p = end <= value || !nsCRT::strncasecmp ("true", value, end - value);
|
||||||
else
|
}
|
||||||
options->rot13_p = PR_FALSE;
|
|
||||||
}
|
q = end;
|
||||||
|
if (*q)
|
||||||
q = end;
|
q++;
|
||||||
if (*q)
|
}
|
||||||
q++;
|
|
||||||
}
|
|
||||||
|
/* Compatibility with the "?part=" syntax used in the old (Mozilla 2.0)
|
||||||
|
|
||||||
/* Compatibility with the "?part=" syntax used in the old (Mozilla 2.0)
|
|
||||||
MIME parser.
|
MIME parser.
|
||||||
|
|
||||||
|
Basically, the problem is that the old part-numbering code was totally
|
||||||
|
busted: here's a comparison of the old and new numberings with a pair
|
||||||
|
of hypothetical messages (one with a single part, and one with nested
|
||||||
|
containers.)
|
||||||
|
NEW: OLD: OR:
|
||||||
|
message/rfc822
|
||||||
|
image/jpeg 1 0 0
|
||||||
|
|
||||||
|
message/rfc822
|
||||||
|
multipart/mixed 1 0 0
|
||||||
|
text/plain 1.1 1 1
|
||||||
|
image/jpeg 1.2 2 2
|
||||||
|
message/rfc822 1.3 - 3
|
||||||
|
text/plain 1.3.1 3 -
|
||||||
|
message/rfc822 1.4 - 4
|
||||||
|
multipart/mixed 1.4.1 4 -
|
||||||
|
text/plain 1.4.1.1 4.1 -
|
||||||
|
image/jpeg 1.4.1.2 4.2 -
|
||||||
|
text/plain 1.5 5 5
|
||||||
|
|
||||||
Basically, the problem is that the old part-numbering code was totally
|
The "NEW" column is how the current code counts. The "OLD" column is
|
||||||
busted: here's a comparison of the old and new numberings with a pair
|
what "?part=" references would do in 3.0b4 and earlier; you'll see that
|
||||||
of hypothetical messages (one with a single part, and one with nested
|
you couldn't directly refer to the child message/rfc822 objects at all!
|
||||||
containers.)
|
But that's when it got really weird, because if you turned on
|
||||||
NEW: OLD: OR:
|
"Attachments As Links" (or used a URL like "?inline=false&part=...")
|
||||||
message/rfc822
|
then you got a totally different numbering system (seen in the "OR"
|
||||||
image/jpeg 1 0 0
|
column.) Gag!
|
||||||
|
|
||||||
message/rfc822
|
So, the problem is, ClariNet had been using these part numbers in their
|
||||||
multipart/mixed 1 0 0
|
HTML news feeds, as a sleazy way of transmitting both complex HTML layouts
|
||||||
text/plain 1.1 1 1
|
and images using NNTP as transport, without invoking HTTP.
|
||||||
image/jpeg 1.2 2 2
|
|
||||||
message/rfc822 1.3 - 3
|
The following clause is to provide some small amount of backward
|
||||||
text/plain 1.3.1 3 -
|
compatibility. By looking at that table, one can see that in the new
|
||||||
message/rfc822 1.4 - 4
|
model, "part=0" has no meaning, and neither does "part=2" or "part=3"
|
||||||
multipart/mixed 1.4.1 4 -
|
and so on.
|
||||||
text/plain 1.4.1.1 4.1 -
|
|
||||||
image/jpeg 1.4.1.2 4.2 -
|
"part=1" is ambiguous between the old and new way, as is any part
|
||||||
text/plain 1.5 5 5
|
specification that has a "." in it.
|
||||||
|
|
||||||
The "NEW" column is how the current code counts. The "OLD" column is
|
So, the compatibility hack we do here is: if the part is "0", then map
|
||||||
what "?part=" references would do in 3.0b4 and earlier; you'll see that
|
that to "1". And if the part is >= "2", then prepend "1." to it (so that
|
||||||
you couldn't directly refer to the child message/rfc822 objects at all!
|
we map "2" to "1.2", and "3" to "1.3".)
|
||||||
But that's when it got really weird, because if you turned on
|
|
||||||
"Attachments As Links" (or used a URL like "?inline=false&part=...")
|
This leaves the URLs compatible in the cases of:
|
||||||
then you got a totally different numbering system (seen in the "OR"
|
|
||||||
column.) Gag!
|
= single part messages
|
||||||
|
= references to elements of a top-level multipart except the first
|
||||||
So, the problem is, ClariNet had been using these part numbers in their
|
|
||||||
HTML news feeds, as a sleazy way of transmitting both complex HTML layouts
|
and leaves them incompatible for:
|
||||||
and images using NNTP as transport, without invoking HTTP.
|
|
||||||
|
= the first part of a top-level multipart
|
||||||
The following clause is to provide some small amount of backward
|
= all elements deeper than the outermost part
|
||||||
compatibility. By looking at that table, one can see that in the new
|
|
||||||
model, "part=0" has no meaning, and neither does "part=2" or "part=3"
|
Life s#$%s when you don't properly think out things that end up turning
|
||||||
and so on.
|
into de-facto standards...
|
||||||
|
*/
|
||||||
"part=1" is ambiguous between the old and new way, as is any part
|
|
||||||
specification that has a "." in it.
|
|
||||||
|
|
||||||
So, the compatibility hack we do here is: if the part is "0", then map
|
|
||||||
that to "1". And if the part is >= "2", then prepend "1." to it (so that
|
|
||||||
we map "2" to "1.2", and "3" to "1.3".)
|
|
||||||
|
|
||||||
This leaves the URLs compatible in the cases of:
|
|
||||||
|
|
||||||
= single part messages
|
|
||||||
= references to elements of a top-level multipart except the first
|
|
||||||
|
|
||||||
and leaves them incompatible for:
|
|
||||||
|
|
||||||
= the first part of a top-level multipart
|
|
||||||
= all elements deeper than the outermost part
|
|
||||||
|
|
||||||
Life s#$%s when you don't properly think out things that end up turning
|
|
||||||
into de-facto standards...
|
|
||||||
*/
|
|
||||||
if (options->part_to_load &&
|
|
||||||
!PL_strchr(options->part_to_load, '.')) /* doesn't contain a dot */
|
|
||||||
{
|
|
||||||
if (!nsCRT::strcmp(options->part_to_load, "0")) /* 0 */
|
|
||||||
{
|
|
||||||
PR_Free(options->part_to_load);
|
|
||||||
options->part_to_load = nsCRT::strdup("1");
|
|
||||||
if (!options->part_to_load)
|
|
||||||
return MIME_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
else if (nsCRT::strcmp(options->part_to_load, "1")) /* not 1 */
|
|
||||||
{
|
|
||||||
const char *prefix = "1.";
|
|
||||||
char *s = (char *) PR_MALLOC(strlen(options->part_to_load) +
|
|
||||||
strlen(prefix) + 1);
|
|
||||||
if (!s) return MIME_OUT_OF_MEMORY;
|
|
||||||
PL_strcpy(s, prefix);
|
|
||||||
PL_strcat(s, options->part_to_load);
|
|
||||||
PR_Free(options->part_to_load);
|
|
||||||
options->part_to_load = s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
if (options->part_to_load &&
|
||||||
|
!PL_strchr(options->part_to_load, '.')) /* doesn't contain a dot */
|
||||||
|
{
|
||||||
|
if (!nsCRT::strcmp(options->part_to_load, "0")) /* 0 */
|
||||||
|
{
|
||||||
|
PR_Free(options->part_to_load);
|
||||||
|
options->part_to_load = nsCRT::strdup("1");
|
||||||
|
if (!options->part_to_load)
|
||||||
|
return MIME_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
else if (nsCRT::strcmp(options->part_to_load, "1")) /* not 1 */
|
||||||
|
{
|
||||||
|
const char *prefix = "1.";
|
||||||
|
char *s = (char *) PR_MALLOC(strlen(options->part_to_load) +
|
||||||
|
strlen(prefix) + 1);
|
||||||
|
if (!s) return MIME_OUT_OF_MEMORY;
|
||||||
|
PL_strcpy(s, prefix);
|
||||||
|
PL_strcat(s, options->part_to_load);
|
||||||
|
PR_Free(options->part_to_load);
|
||||||
|
options->part_to_load = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1954,6 +1962,18 @@ mime_get_base_url(const char *url)
|
|||||||
return nsnull;
|
return nsnull;
|
||||||
|
|
||||||
const char *s = strrchr(url, '?');
|
const char *s = strrchr(url, '?');
|
||||||
|
if (s && !strncmp(s, "?type=application/x-message-display", sizeof("?type=application/x-message-display") - 1))
|
||||||
|
{
|
||||||
|
const char *nextTerm = strchr(s, '&');
|
||||||
|
s = (nextTerm) ? nextTerm : s + strlen(s) - 1;
|
||||||
|
}
|
||||||
|
// we need to keep the ?number part of the url, or we won't know
|
||||||
|
// which local message the part belongs to.
|
||||||
|
if (s && *s && *(s+1) && !strncmp(s + 1, "number=", sizeof("number=") - 1))
|
||||||
|
{
|
||||||
|
const char *nextTerm = strchr(++s, '&');
|
||||||
|
s = (nextTerm) ? nextTerm : s + strlen(s) - 1;
|
||||||
|
}
|
||||||
char *result = (char *) PR_MALLOC(strlen(url) + 1);
|
char *result = (char *) PR_MALLOC(strlen(url) + 1);
|
||||||
NS_ASSERTION(result, "out of memory");
|
NS_ASSERTION(result, "out of memory");
|
||||||
if (!result)
|
if (!result)
|
||||||
|
@ -408,7 +408,7 @@ nsStreamConverter::DetermineOutputFormat(const char *aUrl, nsMimeOutputType *aNe
|
|||||||
|
|
||||||
// is this is a part that should just come out raw
|
// is this is a part that should just come out raw
|
||||||
const char *part = FindQueryElementData(queryPart, "part=");
|
const char *part = FindQueryElementData(queryPart, "part=");
|
||||||
if (part)
|
if (part && !mToType.Equals("application/vnd.mozilla.xul+xml"))
|
||||||
{
|
{
|
||||||
// default for parts
|
// default for parts
|
||||||
mOutputFormat = "raw";
|
mOutputFormat = "raw";
|
||||||
@ -486,7 +486,7 @@ nsStreamConverter::DetermineOutputFormat(const char *aUrl, nsMimeOutputType *aNe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// default to html for just the body
|
// default to html for just the body
|
||||||
mOutputFormat = "text/html";
|
mOutputFormat = "text/html";
|
||||||
*aNewType = nsMimeOutput::nsMimeMessageBodyDisplay;
|
*aNewType = nsMimeOutput::nsMimeMessageBodyDisplay;
|
||||||
@ -548,7 +548,7 @@ NS_IMETHODIMP nsStreamConverter::Init(nsIURI *aURI, nsIStreamListener * aOutList
|
|||||||
|
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
mOutListener = aOutListener;
|
mOutListener = aOutListener;
|
||||||
|
|
||||||
// mscott --> we need to look at the url and figure out what the correct output type is...
|
// mscott --> we need to look at the url and figure out what the correct output type is...
|
||||||
nsMimeOutputType newType = mOutputType;
|
nsMimeOutputType newType = mOutputType;
|
||||||
if (!mAlreadyKnowOutputType)
|
if (!mAlreadyKnowOutputType)
|
||||||
@ -1087,7 +1087,7 @@ NS_IMETHODIMP nsStreamConverter::AsyncConvertData(const char *aFromType,
|
|||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
nsCOMPtr<nsIMsgQuote> aMsgQuote = do_QueryInterface(aCtxt, &rv);
|
nsCOMPtr<nsIMsgQuote> aMsgQuote = do_QueryInterface(aCtxt, &rv);
|
||||||
nsCOMPtr<nsIChannel> aChannel;
|
nsCOMPtr<nsIChannel> aChannel;
|
||||||
|
|
||||||
if (aMsgQuote)
|
if (aMsgQuote)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIMimeStreamConverterListener> quoteListener;
|
nsCOMPtr<nsIMimeStreamConverterListener> quoteListener;
|
||||||
@ -1101,6 +1101,9 @@ NS_IMETHODIMP nsStreamConverter::AsyncConvertData(const char *aFromType,
|
|||||||
aChannel = do_QueryInterface(aCtxt, &rv);
|
aChannel = do_QueryInterface(aCtxt, &rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mFromType = aFromType;
|
||||||
|
mToType = aToType;
|
||||||
|
|
||||||
NS_ASSERTION(aChannel && NS_SUCCEEDED(rv), "mailnews mime converter has to have the channel passed in...");
|
NS_ASSERTION(aChannel && NS_SUCCEEDED(rv), "mailnews mime converter has to have the channel passed in...");
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
@ -107,6 +107,8 @@ private:
|
|||||||
nsCOMPtr<nsIMsgIdentity> mIdentity;
|
nsCOMPtr<nsIMsgIdentity> mIdentity;
|
||||||
nsCString mOriginalMsgURI;
|
nsCString mOriginalMsgURI;
|
||||||
|
|
||||||
|
nsCString mFromType;
|
||||||
|
nsCString mToType;
|
||||||
#ifdef DEBUG_mscott
|
#ifdef DEBUG_mscott
|
||||||
PRTime mConvertContentTime;
|
PRTime mConvertContentTime;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user