зеркало из https://github.com/mozilla/pjs.git
fix for #63225. "Save Image As" from a message provides a bogus image filename.
remove some dead code. r=ducarroz, sr=mscott,sspitzer.
This commit is contained in:
Родитель
369f20ee32
Коммит
f770d64922
|
@ -388,9 +388,28 @@ NS_IMETHODIMP nsMsgMailNewsUrl::GetSpec(char * *aSpec)
|
|||
return m_baseURL->GetSpec(aSpec);
|
||||
}
|
||||
|
||||
#define FILENAME_PART "&filename="
|
||||
#define FILENAME_PART_LEN 10
|
||||
|
||||
NS_IMETHODIMP nsMsgMailNewsUrl::SetSpec(const char * aSpec)
|
||||
{
|
||||
return m_baseURL->SetSpec(aSpec);
|
||||
// Parse out "filename" attribute if present.
|
||||
char *start, *end;
|
||||
start = PL_strcasestr(aSpec,FILENAME_PART);
|
||||
if (start)
|
||||
{ // Make sure we only get our own value.
|
||||
end = PL_strcasestr((char*)(start+FILENAME_PART_LEN),"&");
|
||||
if (end)
|
||||
{
|
||||
*end = 0;
|
||||
mAttachmentFileName = start+FILENAME_PART_LEN;
|
||||
*end = '&';
|
||||
}
|
||||
else
|
||||
mAttachmentFileName = start+FILENAME_PART_LEN;
|
||||
}
|
||||
// Now, set the rest.
|
||||
return m_baseURL->SetSpec(aSpec);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgMailNewsUrl::GetPrePath(char * *aPrePath)
|
||||
|
|
|
@ -357,6 +357,8 @@ NS_IMETHODIMP nsImapService::OpenAttachment(const char *aContentType,
|
|||
uri.Append(mimePart);
|
||||
uri += "&type=";
|
||||
uri += aContentType;
|
||||
uri += "&filename=";
|
||||
uri += aFileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -366,6 +368,8 @@ NS_IMETHODIMP nsImapService::OpenAttachment(const char *aContentType,
|
|||
uri += part;
|
||||
uri += "&type=";
|
||||
uri += aContentType;
|
||||
uri += "&filename=";
|
||||
uri += aFileName;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMsgFolder> folder;
|
||||
|
|
|
@ -238,6 +238,8 @@ NS_IMETHODIMP nsMailboxService::OpenAttachment(const char *aContentType,
|
|||
partMsgUrl += part;
|
||||
partMsgUrl += "&type=";
|
||||
partMsgUrl += aContentType;
|
||||
partMsgUrl += "&filename=";
|
||||
partMsgUrl += aFileName;
|
||||
return FetchMessage(partMsgUrl, aDisplayConsumer,
|
||||
aMsgWindow,aUrlListener, aFileName,
|
||||
nsIMailboxUrl::ActionFetchPart, nsnull, nsnull);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "nsMimeTypes.h"
|
||||
#include "nsMimeStringResources.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsEscape.h"
|
||||
|
||||
#define MIME_SUPERCLASS mimeLeafClass
|
||||
MimeDefClass(MimeInlineImage, MimeInlineImageClass,
|
||||
|
@ -109,11 +110,27 @@ MimeInlineImage_parse_begin (MimeObject *obj)
|
|||
ct = obj->content_type;
|
||||
if (!ct) ct = IMAGE_GIF; /* Can't happen? Close enough. */
|
||||
|
||||
// Fill in content type and attachment name here.
|
||||
nsCAutoString url_with_filename(image_url);
|
||||
url_with_filename += "&type=";
|
||||
url_with_filename += ct;
|
||||
char * filename = MimeHeaders_get_name ( obj->headers, obj->options );
|
||||
if (filename)
|
||||
{
|
||||
char *escapedName = nsEscape(filename, url_Path);
|
||||
if (escapedName)
|
||||
{
|
||||
url_with_filename += "&filename=";
|
||||
url_with_filename += escapedName;
|
||||
nsCRT::free(escapedName);
|
||||
}
|
||||
}
|
||||
|
||||
// We need to separate images with HR's...
|
||||
MimeObject_write_separator(obj);
|
||||
|
||||
img->image_data =
|
||||
obj->options->image_begin(image_url, ct, obj->options->stream_closure);
|
||||
obj->options->image_begin(url_with_filename, ct, obj->options->stream_closure);
|
||||
PR_Free(image_url);
|
||||
|
||||
if (!img->image_data) return MIME_OUT_OF_MEMORY;
|
||||
|
|
|
@ -1032,14 +1032,9 @@ mime_image_make_image_html(void *image_closure)
|
|||
const char *url;
|
||||
char *buf;
|
||||
|
||||
static PRInt32 makeUniqueHackID = 1;
|
||||
char makeUniqueHackString[128] = "";
|
||||
|
||||
PR_ASSERT(mid);
|
||||
if (!mid) return 0;
|
||||
|
||||
PR_snprintf(makeUniqueHackString, sizeof(makeUniqueHackString), "&hackID=%d", makeUniqueHackID++);
|
||||
|
||||
/* Internal-external-reconnect only works when going to the screen. */
|
||||
if (!mid->istream)
|
||||
return nsCRT::strdup("<P><CENTER><IMG SRC=\"resource:/res/network/gopher-image.gif\" ALT=\"[Image]\"></CENTER><P>");
|
||||
|
@ -1050,14 +1045,13 @@ mime_image_make_image_html(void *image_closure)
|
|||
url = mid->url;
|
||||
|
||||
buf = (char *) PR_MALLOC (nsCRT::strlen(prefix) + nsCRT::strlen(suffix) +
|
||||
nsCRT::strlen(url) + nsCRT::strlen(makeUniqueHackString) + 20) ;
|
||||
nsCRT::strlen(url) + 20) ;
|
||||
if (!buf)
|
||||
return 0;
|
||||
*buf = 0;
|
||||
|
||||
PL_strcat (buf, prefix);
|
||||
PL_strcat (buf, url);
|
||||
PL_strcat (buf, makeUniqueHackString);
|
||||
PL_strcat (buf, suffix);
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -455,7 +455,16 @@ nsStreamConverter::DetermineOutputFormat(const char *url, nsMimeOutputType *aNe
|
|||
if (typeField)
|
||||
{
|
||||
// store the real content type...mOutputFormat gets deleted later on...
|
||||
// and make sure we only get our own value.
|
||||
char *nextField = PL_strcasestr(typeField + nsCRT::strlen("&type="),"&");
|
||||
if (nextField)
|
||||
{
|
||||
*nextField = 0;
|
||||
mRealContentType = typeField + nsCRT::strlen("&type=");
|
||||
*nextField = '&';
|
||||
}
|
||||
else
|
||||
mRealContentType = typeField + nsCRT::strlen("&type=");
|
||||
if (mRealContentType.Equals("message/rfc822"))
|
||||
{
|
||||
mRealContentType = "text/plain";
|
||||
|
|
|
@ -369,6 +369,8 @@ NS_IMETHODIMP nsNntpService::OpenAttachment(const char *aContentType,
|
|||
newsUrl = aUrl;
|
||||
newsUrl += "&type=";
|
||||
newsUrl += aContentType;
|
||||
newsUrl += "&filename=";
|
||||
newsUrl += aFileName;
|
||||
|
||||
NewURI(newsUrl, nsnull, getter_AddRefs(url));
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче