mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 23:43:39 +00:00
[RAPPS][SHLWAPI][SDK] Un-escape URL filename (#6626)
Choosing the better filename. JIRA issue: CORE-19490 - Add UrlUnescapeAndMakeFileNameValid helper function. - Use UrlUnescapeW and PathIsValidCharW. - Add PATH_CHAR_CLASS_... flags for PathIsValidCharA/W.
This commit is contained in:
parent
dc4992ce4a
commit
1fbf09f531
3 changed files with 47 additions and 1 deletions
|
@ -42,6 +42,7 @@
|
|||
|
||||
#include <ui/rosctrls.h>
|
||||
#include <windowsx.h>
|
||||
#include <shlwapi_undoc.h>
|
||||
#include <process.h>
|
||||
#undef SubclassWindow
|
||||
|
||||
|
@ -80,6 +81,30 @@ LoadStatusString(DownloadStatus StatusParam)
|
|||
return szString;
|
||||
}
|
||||
|
||||
#define FILENAME_VALID_CHAR ( \
|
||||
PATH_CHAR_CLASS_LETTER | \
|
||||
PATH_CHAR_CLASS_DOT | \
|
||||
PATH_CHAR_CLASS_SEMICOLON | \
|
||||
PATH_CHAR_CLASS_COMMA | \
|
||||
PATH_CHAR_CLASS_SPACE | \
|
||||
PATH_CHAR_CLASS_OTHER_VALID)
|
||||
|
||||
VOID
|
||||
UrlUnescapeAndMakeFileNameValid(CStringW& str)
|
||||
{
|
||||
WCHAR szPath[MAX_PATH];
|
||||
DWORD cchPath = _countof(szPath);
|
||||
UrlUnescapeW(const_cast<LPWSTR>((LPCWSTR)str), szPath, &cchPath, 0);
|
||||
|
||||
for (PWCHAR pch = szPath; *pch; ++pch)
|
||||
{
|
||||
if (!PathIsValidCharW(*pch, FILENAME_VALID_CHAR))
|
||||
*pch = L'_';
|
||||
}
|
||||
|
||||
str = szPath;
|
||||
}
|
||||
|
||||
struct DownloadInfo
|
||||
{
|
||||
DownloadInfo()
|
||||
|
@ -710,8 +735,12 @@ CDownloadManager::ThreadFunc(LPVOID param)
|
|||
Path += APPLICATION_DATABASE_NAME;
|
||||
break;
|
||||
case DLTYPE_APPLICATION:
|
||||
Path += (LPWSTR)(p + 1); // use the filename retrieved from URL
|
||||
{
|
||||
CStringW str = p + 1; // use the filename retrieved from URL
|
||||
UrlUnescapeAndMakeFileNameValid(str);
|
||||
Path += str;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((InfoArray[iAppId].DLType == DLTYPE_APPLICATION) && InfoArray[iAppId].szSHA1[0] &&
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue