From 6fe2780f3f9da128b85f55c0a2f74f5de239abf7 Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Sat, 9 Nov 2013 14:31:08 +0000 Subject: [PATCH] [SHELL32] - Quote paths containing spaces when executing shell commands. Patch by Huw Campbell. CORE-7542 #resolve svn path=/trunk/; revision=60895 --- reactos/dll/win32/shell32/openwithmenu.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/reactos/dll/win32/shell32/openwithmenu.cpp b/reactos/dll/win32/shell32/openwithmenu.cpp index ede088be0e2..6648a78d85e 100644 --- a/reactos/dll/win32/shell32/openwithmenu.cpp +++ b/reactos/dll/win32/shell32/openwithmenu.cpp @@ -238,7 +238,12 @@ BOOL COpenWithList::Execute(COpenWithList::SApp *pApp, LPCWSTR pwszFilePath) --cchRemaining; } else if (pApp->wszCmd[++i] == '1') - StringCchCopyExW(pszEnd, cchRemaining, pwszFilePath, &pszEnd, &cchRemaining, 0); + { + if (StrChrW(pwszFilePath, L' ') && cchRemaining > 3) + StringCchPrintfExW(pszEnd, cchRemaining, &pszEnd, &cchRemaining, 0, L"\"%ls\"", pwszFilePath); + else + StringCchCopyExW(pszEnd, cchRemaining, pwszFilePath, &pszEnd, &cchRemaining, 0); + } } /* NULL-terminate the command string */ if (cchRemaining > 0) @@ -1182,7 +1187,7 @@ HRESULT WINAPI COpenWithMenu::QueryContextMenu( /* Load applications list */ m_pAppList->Load(); m_pAppList->LoadRecommended(m_wszPath); - + /* Create submenu only if there is more than one application and menu has a default item */ if (m_pAppList->GetRecommendedCount() > 1) {