зеркало из https://github.com/mozilla/pjs.git
Bug 620140 - Bug 616271 causes CanLoadPlugin returns failure when plugin path is non-ASCII. r=joshmoz a=blocking-beta9+
This commit is contained in:
Родитель
222da5a416
Коммит
0c157bc6e8
|
@ -160,18 +160,14 @@ static void FreeStringArray(PRUint32 variants, char ** array)
|
||||||
PR_Free(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)
|
#if defined(_M_IX86) || defined(_M_X64) || defined(_M_IA64)
|
||||||
PRBool canLoad = PR_FALSE;
|
PRBool canLoad = PR_FALSE;
|
||||||
|
|
||||||
int len = MultiByteToWideChar(CP_UTF8, 0, binaryPath, -1, NULL, 0);
|
HANDLE file = CreateFileW(aBinaryPath, GENERIC_READ,
|
||||||
WCHAR *wBinaryPath = new WCHAR[len];
|
|
||||||
MultiByteToWideChar(CP_UTF8, 0, binaryPath, -1, wBinaryPath, len);
|
|
||||||
HANDLE file = CreateFileW(wBinaryPath, GENERIC_READ,
|
|
||||||
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
|
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
|
||||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
delete[] wBinaryPath;
|
|
||||||
if (file != INVALID_HANDLE_VALUE) {
|
if (file != INVALID_HANDLE_VALUE) {
|
||||||
HANDLE map = CreateFileMappingW(file, NULL, PAGE_READONLY, 0,
|
HANDLE map = CreateFileMappingW(file, NULL, PAGE_READONLY, 0,
|
||||||
GetFileSize(file, NULL), NULL);
|
GetFileSize(file, NULL), NULL);
|
||||||
|
@ -329,17 +325,13 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info, PRLibrary **outLibrary)
|
||||||
if (!mPlugin)
|
if (!mPlugin)
|
||||||
return NS_ERROR_NULL_POINTER;
|
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;
|
nsAutoString fullPath;
|
||||||
if (NS_FAILED(rv = mPlugin->GetPath(fullPath)))
|
if (NS_FAILED(rv = mPlugin->GetPath(fullPath)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
|
if (!CanLoadPlugin(fullPath.get()))
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
nsAutoString fileName;
|
nsAutoString fileName;
|
||||||
if (NS_FAILED(rv = mPlugin->GetLeafName(fileName)))
|
if (NS_FAILED(rv = mPlugin->GetLeafName(fileName)))
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -371,7 +363,7 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info, PRLibrary **outLibrary)
|
||||||
info.fMimeTypeArray = MakeStringArray(info.fVariantCount, mimeType);
|
info.fMimeTypeArray = MakeStringArray(info.fVariantCount, mimeType);
|
||||||
info.fMimeDescriptionArray = MakeStringArray(info.fVariantCount, mimeDescription);
|
info.fMimeDescriptionArray = MakeStringArray(info.fVariantCount, mimeDescription);
|
||||||
info.fExtensionArray = MakeStringArray(info.fVariantCount, extensions);
|
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.fFileName = PL_strdup(NS_ConvertUTF16toUTF8(fileName).get());
|
||||||
info.fVersion = GetVersion(verbuf);
|
info.fVersion = GetVersion(verbuf);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче