From efd40a295c2b4231b30706e040f37662907e0544 Mon Sep 17 00:00:00 2001 From: "METANEOCORTEX\\Kotti" Date: Mon, 27 May 2024 19:57:49 +0200 Subject: [PATCH] +fix: some missing Path_Sanitize() calls --- src/Dialogs.c | 7 ++++++- src/Dlapi.c | 1 + src/Notepad3.c | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Dialogs.c b/src/Dialogs.c index 73a568944..ef94b48b6 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -1523,6 +1523,7 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM l wchar_t* const args_buf = StrgWriteAccessBuf(hargs_str, CMDLN_LENGTH_LIMIT); if (GetDlgItemText(hwnd, IDC_COMMANDLINE, file_buf, (int)Path_GetBufCount(hfile_pth))) { + Path_Sanitize(hfile_pth); bool bQuickExit = false; @@ -2628,6 +2629,7 @@ static INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPAR ListView_GetItem(hwndLV, &lvi); + Path_Sanitize(hFilePath); Path_UnQuoteSpaces(hFilePath); Path_AbsoluteFromApp(hFilePath, true); @@ -5079,8 +5081,11 @@ void DialogGrepWin(HWND hwnd, LPCWSTR searchPattern) if (lngIdx >= 0) { IniSectionGetString(globalSection, L"languagefile", grepWinLangResName[lngIdx].filename, wchLngPathBuf, Path_GetBufCount(hLngFilePath)); IniSectionSetString(globalSection, L"languagefile", wchLngPathBuf); - } else { + Path_Sanitize(hLngFilePath); + } + else { IniSectionGetString(globalSection, L"languagefile", L"", wchLngPathBuf, Path_GetBufCount(hLngFilePath)); + Path_Sanitize(hLngFilePath); if (Path_IsEmpty(hLngFilePath)) { IniSectionDelete(globalSection, L"languagefile", false); } diff --git a/src/Dlapi.c b/src/Dlapi.c index 481154281..69966d011 100644 --- a/src/Dlapi.c +++ b/src/Dlapi.c @@ -813,6 +813,7 @@ bool DirList_SelectItem(HWND hwnd,LPCWSTR lpszDisplayName,LPCWSTR lpszFullPath) DirList_GetItem(hwnd,i,&dli); GetShortPathNameW(dli.pthFileName, dli.pthFileName, (DWORD)Path_GetBufCount(hpthFileName)); + Path_Sanitize(hpthFileName); if (StringCchCompareXI(dli.pthFileName, Path_Get(hshort_pth)) == 0) { ListView_SetItemState(hwnd,i,LVIS_FLAGS,LVIS_FLAGS); diff --git a/src/Notepad3.c b/src/Notepad3.c index 3c7f24fae..a37d7397c 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -3759,6 +3759,7 @@ LRESULT MsgDropFiles(HWND hwnd, WPARAM wParam, LPARAM lParam) for (UINT i = 0; i < cnt; ++i) { WININFO wi = GetMyWindowPlacement(hwnd, NULL, (vkCtrlDown ? (offset * (i + 1)) : 0), bFullVisible); DragQueryFileW(hDrop, i, drop_buf, (UINT)Path_GetBufCount(hdrop_pth)); + Path_Sanitize(hdrop_pth); _OnDropOneFile(hwnd, hdrop_pth, (((0 == i) && !IsKeyDown(VK_CONTROL)) ? NULL : &wi)); } @@ -7976,9 +7977,11 @@ void HandleDWellStartEnd(const DocPos position, const UINT uid) LPWSTR const url_buf = Path_WriteAccessBuf(hurl_pth, cchPath); if (FAILED(PathCreateFromUrlW(wchUrl, url_buf, &cchPath, 0))) { + Path_Sanitize(hurl_pth); const char *p = &pUrlBegin[CONSTSTRGLEN("file://")]; while (p && (*p == '/')) { ++p; } StringCchCopyN(url_buf, Path_GetBufCount(hurl_pth), wchUrl, cchUrl); // no op + Path_Sanitize(hurl_pth); cchPath = (DWORD)Path_GetLength(hurl_pth); } Path_Sanitize(hurl_pth); @@ -9131,6 +9134,7 @@ static LRESULT _MsgNotifyFromEdit(HWND hwnd, const SCNotification* const scn) HPATHL hfile_pth = Path_Allocate(NULL); wchar_t* const file_buf = Path_WriteAccessBuf(hfile_pth, STRINGW_MAX_URL_LENGTH); int const cnt = MultiByteToWideChar(CP_UTF8, 0, scn->text, -1, file_buf, (int)Path_GetBufCount(hfile_pth)); + Path_Sanitize(hfile_pth); LRESULT const result = (cnt > 0) ? _OnDropOneFile(hwnd, hfile_pth, NULL) : FALSE; Path_Release(hfile_pth); return result;