Commit e7427e13 authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

Cleanup the handling of the extension in SHELL_FindExecutable():

- Eliminate the corresponding fixed-size buffer which removes the limitation to 3 character extensions. - Fix handling of the trailing '.' case. - Do a case-insensitive check for the extension in win.ini. Increase the size of the command buffer to 1024.
parent c6c109a3
......@@ -516,10 +516,9 @@ UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpOperation,
static const WCHAR wPrograms[] = {'p','r','o','g','r','a','m','s',0};
static const WCHAR wExtensions[] = {'e','x','e',' ','p','i','f',' ','b','a','t',' ','c','m','d',' ','c','o','m',0};
WCHAR *extension = NULL; /* pointer to file extension */
WCHAR wtmpext[5]; /* local copy to mung as we please */
WCHAR filetype[256]; /* registry name for this filetype */
LONG filetypelen = sizeof(filetype); /* length of above */
WCHAR command[256]; /* command from registry */
WCHAR command[1024]; /* command from registry */
WCHAR wBuffer[256]; /* Used to GetProfileString */
UINT retval = 31; /* default - 'No association was found' */
WCHAR *tok; /* token pointer */
......@@ -558,17 +557,12 @@ UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpOperation,
/* .\FILE.EXE :( */
TRACE("xlpFile=%s,extension=%s\n", debugstr_w(xlpFile), debugstr_w(extension));
if ((extension == NULL) || (extension == &xlpFile[strlenW(xlpFile)]))
if (extension == NULL || extension[1]==0)
{
WARN("Returning 31 - No association\n");
return 31; /* no association */
}
/* Make local copy & lowercase it for reg & 'programs=' lookup */
lstrcpynW(wtmpext, extension, 5);
CharLowerW(wtmpext);
TRACE("%s file\n", debugstr_w(wtmpext));
/* Three places to check: */
/* 1. win.ini, [windows], programs (NB no leading '.') */
/* 2. Registry, HKEY_CLASS_ROOT\<filetype>\shell\open\command */
......@@ -594,7 +588,7 @@ UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpOperation,
while (*p == ' ' || *p == '\t') p++;
}
if (strcmpW(tok, &wtmpext[1]) == 0) /* have to skip the leading "." */
if (strcmpiW(tok, &extension[1]) == 0) /* have to skip the leading "." */
{
strcpyW(lpResult, xlpFile);
/* Need to perhaps check that the file has a path
......@@ -612,7 +606,7 @@ UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpOperation,
}
/* Check registry */
if (RegQueryValueW(HKEY_CLASSES_ROOT, wtmpext, filetype,
if (RegQueryValueW(HKEY_CLASSES_ROOT, extension, filetype,
&filetypelen) == ERROR_SUCCESS)
{
filetypelen /= sizeof(WCHAR);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment