Bug 237944 - The name of Bookmark dragged from IE is the same as URL, r=enn sr=roc

This commit is contained in:
Marco Bonardo 2009-03-27 15:31:12 +01:00
Родитель 52dde58324
Коммит 3b372ec849
1 изменённых файлов: 14 добавлений и 3 удалений

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

@ -758,16 +758,27 @@ nsClipboard :: FindURLFromLocalFile ( IDataObject* inDataObject, UINT inIndex, v
const nsDependentString filepath(static_cast<PRUnichar*>(*outData)); const nsDependentString filepath(static_cast<PRUnichar*>(*outData));
nsCOMPtr<nsILocalFile> file; nsCOMPtr<nsILocalFile> file;
nsresult rv = NS_NewLocalFile(filepath, PR_TRUE, getter_AddRefs(file)); nsresult rv = NS_NewLocalFile(filepath, PR_TRUE, getter_AddRefs(file));
if (NS_FAILED(rv)) if (NS_FAILED(rv)) {
nsMemory::Free(*outData);
return dataFound; return dataFound;
}
if ( IsInternetShortcut(filepath) ) { if ( IsInternetShortcut(filepath) ) {
nsMemory::Free(*outData);
nsCAutoString url; nsCAutoString url;
ResolveShortcut( file, url ); ResolveShortcut( file, url );
if ( !url.IsEmpty() ) { if ( !url.IsEmpty() ) {
// convert it to unicode and pass it out // convert it to unicode and pass it out
nsMemory::Free(*outData); nsDependentString urlString(UTF8ToNewUnicode(url));
*outData = UTF8ToNewUnicode(url); // the internal mozilla URL format, text/x-moz-url, contains
// URL\ntitle. We can guess the title from the file's name.
nsAutoString title;
file->GetLeafName(title);
// We rely on IsInternetShortcut check that file has a .url extension.
title.SetLength(title.Length() - 4);
if (title.IsEmpty())
title = urlString;
*outData = ToNewUnicode(urlString + NS_LITERAL_STRING("\n") + title);
*outDataLen = nsCRT::strlen(static_cast<PRUnichar*>(*outData)) * sizeof(PRUnichar); *outDataLen = nsCRT::strlen(static_cast<PRUnichar*>(*outData)) * sizeof(PRUnichar);
dataFound = PR_TRUE; dataFound = PR_TRUE;