Bug 161156 - Attached URL with JA chars can't be shown correctly in mail window. r=standard8

This commit is contained in:
Makoto Kato 2010-04-09 18:46:49 +09:00
Родитель 5933531971
Коммит dc2f071e88
8 изменённых файлов: 66 добавлений и 34 удалений

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

@ -37,7 +37,7 @@
#include "nsISupports.idl"
[scriptable, uuid(3f92b7c0-8679-4dc6-9af9-9da5546db5b0)]
[scriptable, uuid(98f03f72-8b29-4c49-8975-b45fc08a6a82)]
interface nsIMsgAttachment : nsISupports {
/**
@ -53,7 +53,7 @@ interface nsIMsgAttachment : nsISupports {
*
* @specify where the attachment live (localy or remotely)
*/
attribute string url;
attribute AUTF8String url;
/**
* urlCharset attribute

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

@ -132,7 +132,7 @@ interface nsIMsgComposeRecyclingListener : nsISupports {
void onReopen(in nsIMsgComposeParams params);
};
[scriptable, uuid(d06508a0-23b1-4f14-a29c-f61a478d5500)]
[scriptable, uuid(85d1f6be-6be3-4d55-8ef0-2c8c176dc5d5)]
interface nsIMsgCompose : nsIMsgSendListener {
/* ... */
@ -165,7 +165,7 @@ interface nsIMsgCompose : nsIMsgSendListener {
charset. In case of URL, |charset| parameter will be used in the conversion.
This UI utility function should probably go into it's own class
*/
AUTF8String AttachmentPrettyName(in string url, in string charset);
AUTF8String AttachmentPrettyName(in AUTF8String url, in string charset);
/**
* checkAndPopulateRecipients can perform several tasks (see params), the

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

@ -66,14 +66,13 @@ NS_IMETHODIMP nsMsgAttachment::SetName(const nsAString & aName)
}
/* attribute string url; */
NS_IMETHODIMP nsMsgAttachment::GetUrl(char * *aUrl)
NS_IMETHODIMP nsMsgAttachment::GetUrl(nsACString & aUrl)
{
NS_ENSURE_ARG_POINTER(aUrl);
*aUrl = ToNewCString(mUrl);
return (*aUrl ? NS_OK : NS_ERROR_OUT_OF_MEMORY);
aUrl = mUrl;
return NS_OK;
}
NS_IMETHODIMP nsMsgAttachment::SetUrl(const char * aUrl)
NS_IMETHODIMP nsMsgAttachment::SetUrl(const nsACString & aUrl)
{
mUrl = aUrl;
return NS_OK;
@ -206,8 +205,8 @@ NS_IMETHODIMP nsMsgAttachment::EqualsUrl(nsIMsgAttachment *attachment, PRBool *_
NS_ENSURE_ARG_POINTER(attachment);
NS_ENSURE_ARG_POINTER(_retval);
nsCString url;
attachment->GetUrl(getter_Copies(url));
nsCAutoString url;
attachment->GetUrl(url);
*_retval = mUrl.Equals(url);
return NS_OK;

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

@ -103,7 +103,6 @@
#include "nsIMarkupDocumentViewer.h"
#include "nsIMsgMdnGenerator.h"
#include "plbase64.h"
#include "nsIUTF8ConverterService.h"
#include "nsUConvCID.h"
#include "nsIUnicodeNormalizer.h"
#include "nsIMsgAccountManager.h"
@ -114,6 +113,7 @@
#include "nsIMutableArray.h"
#include "nsArrayUtils.h"
#include "nsIMsgWindow.h"
#include "nsITextToSubURI.h"
static void GetReplyHeaderInfo(PRInt32* reply_header_type,
nsString& reply_header_locale,
@ -1239,7 +1239,7 @@ NS_IMETHODIMP nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity
attachment->SetName(NS_ConvertASCIItoUTF16(userid));
}
attachment->SetUrl(vCardUrl.get());
attachment->SetUrl(vCardUrl);
m_compFields->AddAttachment(attachment);
}
}
@ -2055,7 +2055,7 @@ nsresult nsMsgCompose::CreateMessage(const char * originalMsgURI,
// change all '.' to '_' see bug #271211
sanitizedSubj.ReplaceChar('.', '_');
attachment->SetName(addExtension ? sanitizedSubj + NS_LITERAL_STRING(".eml") : sanitizedSubj);
attachment->SetUrl(uri);
attachment->SetUrl(nsDependentCString(uri));
m_compFields->AddAttachment(attachment);
}
@ -4402,20 +4402,16 @@ nsresult nsMsgCompose::NotifyStateListeners(PRInt32 aNotificationType, nsresult
return NS_OK;
}
nsresult nsMsgCompose::AttachmentPrettyName(const char* scheme, const char* charset, nsACString& _retval)
nsresult nsMsgCompose::AttachmentPrettyName(const nsACString & scheme, const char* charset, nsACString& _retval)
{
nsresult rv;
nsCOMPtr<nsIUTF8ConverterService> utf8Cvt =
do_GetService(NS_UTF8CONVERTERSERVICE_CONTRACTID);
NS_ENSURE_TRUE(utf8Cvt, NS_ERROR_UNEXPECTED);
nsCAutoString utf8Scheme;
if (PL_strncasestr(scheme, "file:", 5))
if (StringHead(scheme, 5).LowerCaseEqualsLiteral("file:"))
{
nsCOMPtr<nsIFile> file;
rv = NS_GetFileFromURLSpec(nsDependentCString(scheme),
rv = NS_GetFileFromURLSpec(scheme,
getter_AddRefs(file));
NS_ENSURE_SUCCESS(rv, rv);
nsAutoString leafName;
@ -4427,17 +4423,19 @@ nsresult nsMsgCompose::AttachmentPrettyName(const char* scheme, const char* char
// To work around a mysterious bug in VC++ 6.
const char* cset = (!charset || !*charset) ? "UTF-8" : charset;
rv = utf8Cvt->ConvertURISpecToUTF8(nsDependentCString(scheme),
cset, utf8Scheme);
nsCOMPtr<nsITextToSubURI> textToSubURI = do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoString retUrl;
rv = textToSubURI->UnEscapeURIForUI(nsDependentCString(cset), scheme, retUrl);
if (NS_SUCCEEDED(rv)) {
// Some ASCII characters still need to be escaped.
NS_UnescapeURL(utf8Scheme.get(), utf8Scheme.Length(),
esc_SkipControl | esc_AlwaysCopy, _retval);
CopyUTF16toUTF8(retUrl, _retval);
} else {
_retval.Assign(scheme);
}
if (PL_strncasestr(scheme, "http:", 5))
if (StringHead(scheme, 5).LowerCaseEqualsLiteral("http:"))
_retval.Cut(0, 7);
return NS_OK;

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

@ -2148,7 +2148,7 @@ nsMsgComposeAndSend::CountCompFieldAttachments()
nsCOMPtr<nsIMsgAttachment> attachment = do_QueryInterface(element, &rv);
if (NS_SUCCEEDED(rv) && attachment)
{
attachment->GetUrl(getter_Copies(url));
attachment->GetUrl(url);
if (!url.IsEmpty())
{
// Check to see if this is a file URL, if so, don't retrieve
@ -2204,7 +2204,7 @@ nsMsgComposeAndSend::AddCompFieldLocalAttachments()
nsCOMPtr<nsIMsgAttachment> attachment = do_QueryInterface(element, &rv);
if (NS_SUCCEEDED(rv) && attachment)
{
attachment->GetUrl(getter_Copies(url));
attachment->GetUrl(url);
if (!url.IsEmpty())
{
// Just look for local file:// attachments and do the right thing.
@ -2381,7 +2381,7 @@ nsMsgComposeAndSend::AddCompFieldRemoteAttachments(PRUint32 aStartLocation,
nsCOMPtr<nsIMsgAttachment> attachment = do_QueryInterface(element, &rv);
if (NS_SUCCEEDED(rv) && attachment)
{
attachment->GetUrl(getter_Copies(url));
attachment->GetUrl(url);
if (!url.IsEmpty())
{
// Just look for files that are NOT local file attachments and do

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

@ -0,0 +1,35 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* attachment test using non-ascii character
*/
const nonAsciiUrl = "http://\u65e5\u672c\u8a9e.jp";
const prettyResult = "\u65e5\u672c\u8a9e.jp";
function doAttachmentUrlTest() {
// handles non-ascii url in nsIMsgAttachment
var attachment = Cc["@mozilla.org/messengercompose/attachment;1"]
.createInstance(Ci.nsIMsgAttachment);
attachment.url = nonAsciiUrl;
do_check_eq(attachment.url, nonAsciiUrl);
}
function doPrettyNameTest() {
// handles non-ascii url in nsIMsgCompose
var msgCompose = Cc["@mozilla.org/messengercompose/compose;1"]
.createInstance(Ci.nsIMsgCompose);
do_check_eq(msgCompose.AttachmentPrettyName(nonAsciiUrl, null),
prettyResult);
}
function run_test() {
doAttachmentUrlTest();
doPrettyNameTest();
do_test_finished();
}

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

@ -575,7 +575,7 @@ nsresult nsMapiHook::HandleAttachments (nsIMsgCompFields * aCompFields, PRInt32
// now set the attachment object
nsCAutoString pURL ;
NS_GetURLSpecFromFile(pFile, pURL);
attachment->SetUrl(pURL.get()) ;
attachment->SetUrl(pURL);
// add the attachment
rv = aCompFields->AddAttachment (attachment);
@ -810,7 +810,7 @@ nsresult nsMapiHook::PopulateCompFieldsForSendDocs(nsIMsgCompFields * aCompField
// now set the attachment object
nsCAutoString pURL ;
NS_GetURLSpecFromFile(pTempDir, pURL);
attachment->SetUrl(pURL.get()) ;
attachment->SetUrl(pURL);
// add the attachment
rv = aCompFields->AddAttachment (attachment);

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

@ -213,7 +213,7 @@ nsresult CreateComposeParams(nsCOMPtr<nsIMsgComposeParams> &pMsgComposeParams,
if (NS_FAILED(rv))
CopyASCIItoUTF16(nsDependentCString(curAttachment->real_name), nameStr);
attachment->SetName(nameStr);
attachment->SetUrl(spec.get());
attachment->SetUrl(spec);
attachment->SetTemporary(PR_TRUE);
attachment->SetContentType(curAttachment->real_type);
attachment->SetMacType(curAttachment->x_mac_type);