final patch for bug 109179 "replace nsStdEscape with NS_EscapeURL"

r=dougt, sr=alecf
This commit is contained in:
darin%netscape.com 2002-02-05 03:08:15 +00:00
Родитель d3a61dde4e
Коммит 96d9e2d527
6 изменённых файлов: 145 добавлений и 150 удалений

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

@ -629,15 +629,14 @@ nsMsgFolder::parseURI(PRBool needServer)
if (mName.IsEmpty()) {
// mName:
// the name is the trailing directory in the path
nsXPIDLCString fileName;
rv = url->GetFileName(getter_Copies(fileName));
if (NS_SUCCEEDED(rv) && (const char*)fileName != nsnull) {
char *fileName = nsnull;
url->GetFileName(&fileName);
if (fileName) {
// XXX conversion to unicode here? is fileName in UTF8?
// yes, let's say it is in utf8
nsXPIDLCString result;
rv = nsStdUnescape((char*)fileName.get(), getter_Copies(result));
mName.AssignWithConversion(result);
// yes, let's say it is in utf8
NS_UnescapeURL(fileName);
mName = NS_ConvertUTF8toUCS2(fileName);
nsMemory::Free(fileName);
}
}
@ -689,22 +688,24 @@ nsMsgFolder::parseURI(PRBool needServer)
// now try to find the local path for this folder
if (server) {
nsXPIDLCString urlPath;
url->GetFilePath(getter_Copies(urlPath));
nsXPIDLCString result;
rv = nsStdUnescape((char*)urlPath.get(), getter_Copies(result));
// transform the filepath from the URI, such as
// "/folder1/folder2/foldern"
// to
// "folder1.sbd/folder2.sbd/foldern"
// (remove leading / and add .sbd to first n-1 folders)
// to be appended onto the server's path
nsCAutoString newPath;
NS_MsgCreatePathStringFromFolderURI(result, newPath);
char *urlPath = nsnull;
url->GetFilePath(&urlPath);
if (urlPath) {
NS_UnescapeURL(urlPath);
// transform the filepath from the URI, such as
// "/folder1/folder2/foldern"
// to
// "folder1.sbd/folder2.sbd/foldern"
// (remove leading / and add .sbd to first n-1 folders)
// to be appended onto the server's path
NS_MsgCreatePathStringFromFolderURI(urlPath, newPath);
nsMemory::Free(urlPath);
}
// now append munged path onto server path
nsCOMPtr<nsIFileSpec> serverPath;

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

@ -1545,28 +1545,24 @@ QuotingOutputStreamListener::QuotingOutputStreamListener(const char * originalMs
if (! mHeadersOnly)
{
nsXPIDLString replyHeaderOriginalmessage;
// For the built message body...
nsCOMPtr <nsIMsgDBHdr> originalMsgHdr;
rv = GetMsgDBHdrFromURI(originalMsgURI, getter_AddRefs(originalMsgHdr));
if (NS_SUCCEEDED(rv) && originalMsgHdr && !quoteHeaders)
// For the built message body...
nsCOMPtr <nsIMsgDBHdr> originalMsgHdr;
rv = GetMsgDBHdrFromURI(originalMsgURI, getter_AddRefs(originalMsgHdr));
if (NS_SUCCEEDED(rv) && originalMsgHdr && !quoteHeaders)
{
// Setup the cite information....
nsXPIDLCString myGetter;
if (NS_SUCCEEDED(originalMsgHdr->GetMessageId(getter_Copies(myGetter))))
{
nsCString unencodedURL(myGetter);
// would be nice, if nsXPIDL*String were ns*String
nsCAutoString encodedURL;
if (!unencodedURL.IsEmpty() && NS_SUCCEEDED(rv))
if (!myGetter.IsEmpty())
{
if (NS_SUCCEEDED(nsStdEscape(unencodedURL.get(),
esc_FileBaseName | esc_Forced, encodedURL )))
{
mCiteReference = NS_LITERAL_STRING("mid:");
mCiteReference.AppendWithConversion(encodedURL.get());
}
const char *escapedMessageId;
nsCAutoString buf;
if (NS_EscapeURLPart(myGetter.get(), myGetter.Length(), esc_FileBaseName | esc_Forced, buf))
escapedMessageId = buf.get();
else
mCiteReference.Truncate();
escapedMessageId = myGetter.get();
mCiteReference = NS_LITERAL_STRING("mid") + NS_ConvertASCIItoUCS2(escapedMessageId);
}
}

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

@ -83,138 +83,140 @@ NS_IMPL_ISUPPORTS_INHERITED2(nsMsgMailboxParser, nsParseMailMessageState, nsIStr
NS_IMETHODIMP nsMsgMailboxParser::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset,
PRUint32 aLength)
{
// right now, this really just means turn around and process the url
nsresult rv = NS_OK;
nsCOMPtr<nsIURI> url = do_QueryInterface(ctxt, &rv);
if (NS_SUCCEEDED(rv))
rv = ProcessMailboxInputStream(url, aIStream, aLength);
return rv;
// right now, this really just means turn around and process the url
nsresult rv = NS_OK;
nsCOMPtr<nsIURI> url = do_QueryInterface(ctxt, &rv);
if (NS_SUCCEEDED(rv))
rv = ProcessMailboxInputStream(url, aIStream, aLength);
return rv;
}
NS_IMETHODIMP nsMsgMailboxParser::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
{
nsTime currentTime;
m_startTime = currentTime;
nsTime currentTime;
m_startTime = currentTime;
// extract the appropriate event sinks from the url and initialize them in our protocol data
// the URL should be queried for a nsIMailboxURL. If it doesn't support a mailbox URL interface then
// we have an error.
nsresult rv = NS_OK;
// extract the appropriate event sinks from the url and initialize them in our protocol data
// the URL should be queried for a nsIMailboxURL. If it doesn't support a mailbox URL interface then
// we have an error.
nsresult rv = NS_OK;
nsCOMPtr<nsIIOService> ioServ(do_GetService(kIOServiceCID, &rv));
nsCOMPtr<nsIMailboxUrl> runningUrl = do_QueryInterface(ctxt, &rv);
nsCOMPtr<nsIMailboxUrl> runningUrl = do_QueryInterface(ctxt, &rv);
nsCOMPtr<nsIMsgMailNewsUrl> url = do_QueryInterface(ctxt);
nsCOMPtr<nsIMsgMailNewsUrl> url = do_QueryInterface(ctxt);
if (NS_SUCCEEDED(rv) && runningUrl)
{
url->GetStatusFeedback(getter_AddRefs(m_statusFeedback));
if (NS_SUCCEEDED(rv) && runningUrl)
{
url->GetStatusFeedback(getter_AddRefs(m_statusFeedback));
// okay, now fill in our event sinks...Note that each getter ref counts before
// it returns the interface to us...we'll release when we are done
nsXPIDLCString fileName;
nsXPIDLCString folderName;
rv = url->GetFilePath(getter_Copies(fileName));
url->GetFileName(getter_Copies(folderName));
// okay, now fill in our event sinks...Note that each getter ref counts before
// it returns the interface to us...we'll release when we are done
char *fileName = nsnull; // may be shortened by NS_UnescapeURL
url->GetFilePath(&fileName);
nsXPIDLCString tempfolder;
rv = nsStdUnescape((char*)folderName.get(), getter_Copies(tempfolder));
char *folderName = nsnull; // may be shortened by NS_UnescapeURL
url->GetFileName(&folderName);
if (folderName)
{
NS_UnescapeURL(folderName);
// convert from OS native charset to unicode
rv = ConvertToUnicode(nsMsgI18NFileSystemCharset(), tempfolder, m_folderName);
if (NS_FAILED(rv))
m_folderName.AssignWithConversion(tempfolder);
// convert from OS native charset to unicode
rv = ConvertToUnicode(nsMsgI18NFileSystemCharset(), folderName, m_folderName);
if (NS_FAILED(rv))
m_folderName.AssignWithConversion(folderName);
if (fileName)
{
char* result = nsnull;
rv = nsStdUnescape((char*)fileName.get(), &result);
nsFilePath dbPath(result);
CRTFREEIF(result);
nsFileSpec dbName(dbPath);
nsMemory::Free(folderName);
}
// the size of the mailbox file is our total base line for measuring progress
m_graph_progress_total = dbName.GetFileSize();
UpdateStatusText(LOCAL_STATUS_SELECTING_MAILBOX);
nsCOMPtr<nsIMsgDatabase> mailDB;
rv = nsComponentManager::CreateInstance(kCMailDB, nsnull, NS_GET_IID(nsIMsgDatabase), (void **) getter_AddRefs(mailDB));
if (NS_SUCCEEDED(rv) && mailDB)
{
nsCOMPtr <nsIFileSpec> dbFileSpec;
NS_NewFileSpecWithSpec(dbName, getter_AddRefs(dbFileSpec));
rv = mailDB->Open(dbFileSpec, PR_TRUE, PR_TRUE, (nsIMsgDatabase **) getter_AddRefs(m_mailDB));
if (m_mailDB)
m_mailDB->AddListener(this);
}
NS_ASSERTION(m_mailDB, "failed to open mail db parsing folder");
if (fileName)
{
NS_UnescapeURL(fileName);
nsFilePath dbPath(fileName);
nsFileSpec dbName(dbPath);
// the size of the mailbox file is our total base line for measuring progress
m_graph_progress_total = dbName.GetFileSize();
UpdateStatusText(LOCAL_STATUS_SELECTING_MAILBOX);
nsCOMPtr<nsIMsgDatabase> mailDB;
rv = nsComponentManager::CreateInstance(kCMailDB, nsnull, NS_GET_IID(nsIMsgDatabase), (void **) getter_AddRefs(mailDB));
if (NS_SUCCEEDED(rv) && mailDB)
{
nsCOMPtr <nsIFileSpec> dbFileSpec;
NS_NewFileSpecWithSpec(dbName, getter_AddRefs(dbFileSpec));
rv = mailDB->Open(dbFileSpec, PR_TRUE, PR_TRUE, (nsIMsgDatabase **) getter_AddRefs(m_mailDB));
if (m_mailDB)
m_mailDB->AddListener(this);
}
NS_ASSERTION(m_mailDB, "failed to open mail db parsing folder");
#ifdef DEBUG_mscott
printf("url file = %s\n", (const char *)fileName);
printf("url file = %s\n", fileName);
#endif
}
}
// need to get the mailbox name out of the url and call SetMailboxName with it.
// then, we need to open the mail db for this parser.
return rv;
nsMemory::Free(fileName);
}
}
// need to get the mailbox name out of the url and call SetMailboxName with it.
// then, we need to open the mail db for this parser.
return rv;
}
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
NS_IMETHODIMP nsMsgMailboxParser::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus)
{
DoneParsingFolder(aStatus);
// what can we do? we can close the stream?
m_urlInProgress = PR_FALSE; // don't close the connection...we may be re-using it.
DoneParsingFolder(aStatus);
// what can we do? we can close the stream?
m_urlInProgress = PR_FALSE; // don't close the connection...we may be re-using it.
if (m_mailDB)
m_mailDB->RemoveListener(this);
// and we want to mark ourselves for deletion or some how inform our protocol manager that we are
// available for another url if there is one....
if (m_mailDB)
m_mailDB->RemoveListener(this);
// and we want to mark ourselves for deletion or some how inform our protocol manager that we are
// available for another url if there is one....
#ifdef DEBUG1
// let's dump out the contents of our db, if possible.
if (m_mailDB)
{
nsMsgKeyArray keys;
nsCAutoString author;
nsCAutoString subject;
// let's dump out the contents of our db, if possible.
if (m_mailDB)
{
nsMsgKeyArray keys;
nsCAutoString author;
nsCAutoString subject;
// m_mailDB->PrePopulate();
m_mailDB->ListAllKeys(keys);
// m_mailDB->PrePopulate();
m_mailDB->ListAllKeys(keys);
PRUint32 size = keys.GetSize();
for (PRUint32 keyindex = 0; keyindex < size; keyindex++)
{
nsCOMPtr<nsIMsgDBHdr> msgHdr;
nsresult ret =
for (PRUint32 keyindex = 0; keyindex < size; keyindex++)
{
nsCOMPtr<nsIMsgDBHdr> msgHdr;
nsresult ret =
m_mailDB->GetMsgHdrForKey(keys[keyindex],
getter_AddRefs(msgHdr));
if (NS_SUCCEEDED(ret) && msgHdr)
{
nsMsgKey key;
if (NS_SUCCEEDED(ret) && msgHdr)
{
nsMsgKey key;
msgHdr->GetMessageKey(&key);
msgHdr->GetAuthor(&author);
msgHdr->GetSubject(&subject);
msgHdr->GetMessageKey(&key);
msgHdr->GetAuthor(&author);
msgHdr->GetSubject(&subject);
#ifdef DEBUG_bienvenu
// leak nsString return values...
printf("hdr key = %d, author = %s subject = %s\n", key, author.get(), subject.get());
// leak nsString return values...
printf("hdr key = %d, author = %s subject = %s\n", key, author.get(), subject.get());
#endif
}
}
m_mailDB->Close(PR_TRUE);
}
}
}
m_mailDB->Close(PR_TRUE);
}
#endif
// be sure to clear any status text and progress info..
m_graph_progress_received = 0;
UpdateProgressPercent();
UpdateStatusText(LOCAL_STATUS_DOCUMENT_DONE);
return NS_OK;
// be sure to clear any status text and progress info..
m_graph_progress_received = 0;
UpdateProgressPercent();
UpdateStatusText(LOCAL_STATUS_DOCUMENT_DONE);
return NS_OK;
}

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

@ -1860,19 +1860,18 @@ nsFtpState::Init(nsIFTPChannel* aChannel,
rv = aURL->GetFilePath(&path);
else
rv = mURL->GetPath(&path);
if (NS_FAILED(rv)) return rv;
// Skip leading slash
char* fwdPtr= NS_CONST_CAST(char*, path);
char* fwdPtr= path;
if (fwdPtr && (*fwdPtr == '/'))
fwdPtr++;
if (*fwdPtr != '\0') {
// now unescape it
char *unescPath = nsnull;
nsStdUnescape(fwdPtr,&unescPath);
nsMemory::Free(path);
mPath.Adopt(unescPath);
// now unescape it... %xx reduced inline to resulting character
NS_UnescapeURL(fwdPtr);
mPath.Assign(fwdPtr);
}
nsMemory::Free(path);
// pull any username and/or password out of the uri
nsXPIDLCString uname;

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

@ -201,7 +201,7 @@ private:
nsCOMPtr<nsIURI> mURL; // the uri we're connecting to
PRInt32 mPort; // the port to connect to
nsAutoString mFilename; // url filename (if any)
nsXPIDLCString mPath; // the url's path
nsCString mPath; // the url's path
nsCString mPwd; // login Path
// ****** other vars

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

@ -900,16 +900,13 @@ nsresult nsExternalAppHandler::SetUpTempFile(nsIChannel * aChannel)
{
// try to extract the file name from the url and use that as a first pass as the
// leaf name of our temp file...
nsXPIDLCString leafName;
url->GetFileName(getter_Copies(leafName));
if (leafName.get())
char *leafName = nsnull; // may be shortened by NS_UnescapeURL
url->GetFileName(&leafName);
if (leafName)
{
nsXPIDLCString unescapedFileName;
rv = nsStdUnescape((char*)leafName.get(), getter_Copies(unescapedFileName));
if (NS_SUCCEEDED(rv))
mSuggestedFileName.Assign(NS_ConvertUTF8toUCS2(unescapedFileName));
else
mSuggestedFileName.AssignWithConversion(leafName);
NS_UnescapeURL(leafName);
mSuggestedFileName = NS_ConvertUTF8toUCS2(leafName);
nsMemory::Free(leafName);
}
}