Skip to content

Commit

Permalink
Merge pull request rizonesoft#5198 from RaiKoHoff/Dev_Master
Browse files Browse the repository at this point in the history
Fixing some missing Path_Sanitize() calls
  • Loading branch information
hpwamr committed May 27, 2024
2 parents c9e010f + bc28b51 commit 6541a32
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions src/Dlapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/Notepad3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down Expand Up @@ -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:https://")];
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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 6541a32

Please sign in to comment.