зеркало из https://github.com/mozilla/pjs.git
Changed to escape folder name to prevent 8 bit data from bad conversions,
also changed to apply correct conversions (UTF-8 for RDF, OS native charset for file name), bug 52165, r=putterman, a=alecf.
This commit is contained in:
Родитель
1adb86262f
Коммит
bbfc394a4a
|
@ -36,6 +36,7 @@
|
||||||
#include "nsMsgLocalCID.h"
|
#include "nsMsgLocalCID.h"
|
||||||
#include "nsMsgBaseCID.h"
|
#include "nsMsgBaseCID.h"
|
||||||
#include "nsMsgImapCID.h"
|
#include "nsMsgImapCID.h"
|
||||||
|
#include "nsMsgI18N.h"
|
||||||
|
|
||||||
static NS_DEFINE_CID(kImapUrlCID, NS_IMAPURL_CID);
|
static NS_DEFINE_CID(kImapUrlCID, NS_IMAPURL_CID);
|
||||||
static NS_DEFINE_CID(kCMailboxUrl, NS_MAILBOXURL_CID);
|
static NS_DEFINE_CID(kCMailboxUrl, NS_MAILBOXURL_CID);
|
||||||
|
@ -336,7 +337,17 @@ nsresult NS_MsgHashIfNecessary(nsCAutoString &name)
|
||||||
|
|
||||||
nsresult NS_MsgCreatePathStringFromFolderURI(const char *folderURI, nsCString& pathString)
|
nsresult NS_MsgCreatePathStringFromFolderURI(const char *folderURI, nsCString& pathString)
|
||||||
{
|
{
|
||||||
nsCAutoString oldPath(folderURI);
|
// A file name has to be in native charset, convert from UTF-8.
|
||||||
|
nsCAutoString oldPath;
|
||||||
|
const nsString fileCharset(nsMsgI18NFileSystemCharset());
|
||||||
|
char *nativeString;
|
||||||
|
nsresult rv = ConvertFromUnicode(fileCharset, nsAutoString(NS_ConvertUTF8toUCS2(folderURI)), &nativeString);
|
||||||
|
if (NS_SUCCEEDED(rv))
|
||||||
|
oldPath.Assign(nativeString);
|
||||||
|
else
|
||||||
|
oldPath.Assign(folderURI);
|
||||||
|
PR_FREEIF(nativeString);
|
||||||
|
|
||||||
nsCAutoString pathPiece;
|
nsCAutoString pathPiece;
|
||||||
|
|
||||||
PRInt32 startSlashPos = oldPath.FindChar('/');
|
PRInt32 startSlashPos = oldPath.FindChar('/');
|
||||||
|
|
|
@ -509,18 +509,15 @@ NS_IMETHODIMP nsMsgLocalMailFolder::AddSubfolder(nsAutoString *name,
|
||||||
nsCAutoString uri(mURI);
|
nsCAutoString uri(mURI);
|
||||||
uri.Append('/');
|
uri.Append('/');
|
||||||
|
|
||||||
// Convert from Unicode to filesystem charactorset
|
// URI should use UTF-8
|
||||||
// XXX URI should use UTF-8?
|
|
||||||
// (see RFC2396 Uniform Resource Identifiers (URI): Generic Syntax)
|
// (see RFC2396 Uniform Resource Identifiers (URI): Generic Syntax)
|
||||||
|
|
||||||
const nsString fileCharset(nsMsgI18NFileSystemCharset());
|
char *escapedName = nsEscape(NS_ConvertUCS2toUTF8(name->GetUnicode()), url_Path);
|
||||||
char *convertedName;
|
if (escapedName)
|
||||||
rv = ConvertFromUnicode(fileCharset, *name, &convertedName);
|
{
|
||||||
if (NS_FAILED(rv))
|
uri.Append(escapedName);
|
||||||
return rv;
|
PR_FREEIF(escapedName);
|
||||||
|
}
|
||||||
uri.Append(convertedName);
|
|
||||||
PR_Free((void*) convertedName);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIRDFResource> res;
|
nsCOMPtr<nsIRDFResource> res;
|
||||||
rv = rdf->GetResource(uri.GetBuffer(), getter_AddRefs(res));
|
rv = rdf->GetResource(uri.GetBuffer(), getter_AddRefs(res));
|
||||||
|
|
|
@ -308,8 +308,17 @@ nsresult nsMailboxService::PrepareMessageUrl(const char * aSrcMsgMailboxURI, nsI
|
||||||
nsFileSpec folderPath;
|
nsFileSpec folderPath;
|
||||||
nsMsgKey msgKey;
|
nsMsgKey msgKey;
|
||||||
const char *part = PL_strstr(aSrcMsgMailboxURI, "part=");
|
const char *part = PL_strstr(aSrcMsgMailboxURI, "part=");
|
||||||
|
|
||||||
rv = nsParseLocalMessageURI(aSrcMsgMailboxURI, folderURI, &msgKey);
|
rv = nsParseLocalMessageURI(aSrcMsgMailboxURI, folderURI, &msgKey);
|
||||||
|
|
||||||
|
// Unescape folder name
|
||||||
|
char *unescapedFolderURI = nsCRT::strdup(folderURI);
|
||||||
|
if (unescapedFolderURI)
|
||||||
|
{
|
||||||
|
nsUnescape(unescapedFolderURI);
|
||||||
|
folderURI.Assign(unescapedFolderURI);
|
||||||
|
PR_Free(unescapedFolderURI);
|
||||||
|
}
|
||||||
|
|
||||||
rv = nsLocalURI2Path(kMailboxMessageRootURI, folderURI, folderPath);
|
rv = nsLocalURI2Path(kMailboxMessageRootURI, folderURI, folderPath);
|
||||||
|
|
||||||
if (NS_SUCCEEDED(rv))
|
if (NS_SUCCEEDED(rv))
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
#include "nsRDFCID.h"
|
#include "nsRDFCID.h"
|
||||||
#include "nsIPref.h"
|
#include "nsIPref.h"
|
||||||
#include "nsIRDFService.h"
|
#include "nsIRDFService.h"
|
||||||
|
#include "nsMsgI18N.h"
|
||||||
|
|
||||||
|
|
||||||
static NS_DEFINE_CID(kCMailDB, NS_MAILDB_CID);
|
static NS_DEFINE_CID(kCMailDB, NS_MAILDB_CID);
|
||||||
|
@ -103,7 +104,10 @@ NS_IMETHODIMP nsMsgMailboxParser::OnStartRequest(nsIChannel * /* aChannel */, ns
|
||||||
nsXPIDLCString tempfolder;
|
nsXPIDLCString tempfolder;
|
||||||
rv = ioServ->Unescape(folderName, getter_Copies(tempfolder));
|
rv = ioServ->Unescape(folderName, getter_Copies(tempfolder));
|
||||||
|
|
||||||
m_folderName.Assign(NS_ConvertUTF8toUCS2(tempfolder));
|
// convert from OS native charset to unicode
|
||||||
|
rv = ConvertToUnicode(nsMsgI18NFileSystemCharset(), tempfolder, m_folderName);
|
||||||
|
if (NS_FAILED(rv))
|
||||||
|
m_folderName.AssignWithConversion(tempfolder);
|
||||||
|
|
||||||
if (fileName)
|
if (fileName)
|
||||||
{
|
{
|
||||||
|
|
Загрузка…
Ссылка в новой задаче