Bug 620140 - Bug 616271 causes CanLoadPlugin returns failure when plugin path is non-ASCII. r=joshmoz a=blocking-beta9+

This commit is contained in:
Makoto Kato 2010-12-20 12:52:03 +09:00
Родитель 222da5a416
Коммит 0c157bc6e8
1 изменённых файлов: 6 добавлений и 14 удалений

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

@ -160,18 +160,14 @@ static void FreeStringArray(PRUint32 variants, char ** array)
PR_Free(array);
}
PRBool CanLoadPlugin(const char* binaryPath)
static PRBool CanLoadPlugin(const PRUnichar* aBinaryPath)
{
#if defined(_M_IX86) || defined(_M_X64) || defined(_M_IA64)
PRBool canLoad = PR_FALSE;
int len = MultiByteToWideChar(CP_UTF8, 0, binaryPath, -1, NULL, 0);
WCHAR *wBinaryPath = new WCHAR[len];
MultiByteToWideChar(CP_UTF8, 0, binaryPath, -1, wBinaryPath, len);
HANDLE file = CreateFileW(wBinaryPath, GENERIC_READ,
HANDLE file = CreateFileW(aBinaryPath, GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
delete[] wBinaryPath;
if (file != INVALID_HANDLE_VALUE) {
HANDLE map = CreateFileMappingW(file, NULL, PAGE_READONLY, 0,
GetFileSize(file, NULL), NULL);
@ -329,17 +325,13 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info, PRLibrary **outLibrary)
if (!mPlugin)
return NS_ERROR_NULL_POINTER;
nsCAutoString fullPathUTF8;
if (NS_FAILED(rv = mPlugin->GetNativePath(fullPathUTF8)))
return rv;
if (!CanLoadPlugin(fullPathUTF8.get()))
return NS_ERROR_FAILURE;
nsAutoString fullPath;
if (NS_FAILED(rv = mPlugin->GetPath(fullPath)))
return rv;
if (!CanLoadPlugin(fullPath.get()))
return NS_ERROR_FAILURE;
nsAutoString fileName;
if (NS_FAILED(rv = mPlugin->GetLeafName(fileName)))
return rv;
@ -371,7 +363,7 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info, PRLibrary **outLibrary)
info.fMimeTypeArray = MakeStringArray(info.fVariantCount, mimeType);
info.fMimeDescriptionArray = MakeStringArray(info.fVariantCount, mimeDescription);
info.fExtensionArray = MakeStringArray(info.fVariantCount, extensions);
info.fFullPath = PL_strdup(fullPathUTF8.get());
info.fFullPath = PL_strdup(NS_ConvertUTF16toUTF8(fullPath).get());
info.fFileName = PL_strdup(NS_ConvertUTF16toUTF8(fileName).get());
info.fVersion = GetVersion(verbuf);