mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-25 19:25:43 +00:00
Fix for bug 23109, 23331. Attachment file names are now converted to file system character set and we display only the file name in case of a file url. R=jefft
This commit is contained in:
parent
a465fa6447
commit
8b94105da6
@ -116,6 +116,13 @@ interface nsIMsgCompose : nsISupports {
|
||||
/* ... */
|
||||
void CloseWindow();
|
||||
|
||||
/*
|
||||
AttachmentPrettyName will return only the leafName if the it's a file URL.
|
||||
It will also convert the filename to the right character set.
|
||||
This UI utility function should probably go into it's own class
|
||||
*/
|
||||
wstring AttachmentPrettyName(in wstring url);
|
||||
|
||||
/* ... */
|
||||
attribute nsIEditorShell editor;
|
||||
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "nsIHTMLEditor.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsEscape.h"
|
||||
|
||||
// XXX temporary so we can use the current identity hack -alecf
|
||||
#include "nsIMsgMailSession.h"
|
||||
@ -1886,3 +1887,42 @@ nsresult nsMsgCompose::NotifyStateListeners(TStateListenerNotification aNotifica
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsMsgCompose::AttachmentPrettyName(const PRUnichar* url, PRUnichar** _retval)
|
||||
{
|
||||
nsCAutoString unescapeULR = url;
|
||||
nsUnescape(unescapeULR);
|
||||
if (unescapeULR.IsEmpty())
|
||||
{
|
||||
*_retval = nsCRT::strdup(url);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (PL_strncasestr(unescapeULR, "file:", 5))
|
||||
{
|
||||
nsFileURL fileUrl(url);
|
||||
nsFileSpec fileSpec(fileUrl);
|
||||
char * leafName = fileSpec.GetLeafName();
|
||||
if (leafName && *leafName)
|
||||
{
|
||||
nsAutoString tempStr;
|
||||
nsresult rv = ConvertToUnicode(msgCompFileSystemCharset(), leafName, tempStr);
|
||||
if (NS_FAILED(rv))
|
||||
tempStr = leafName;
|
||||
*_retval = tempStr.ToNewUnicode();
|
||||
nsCRT::free(leafName);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
if (PL_strncasestr(unescapeULR, "http:", 5))
|
||||
{
|
||||
nsAutoString tempStr = &unescapeULR.mBuffer[7];
|
||||
*_retval = tempStr.ToNewUnicode();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*_retval = nsCRT::strdup(url);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user