@joebigelow / wix-1 / commits / 6f062d1e

PathGetDirectory can't be responsible for stripping quotes.

Sean Hall committed May 26, 2022 at 17:32 UTC 6f062d1e816ff8d3127ddcbdc7ee0335873bbab8
2 files changed +33 -6
src/libs/dutil/WixToolset.DUtil/pathutil.cpp
-6
@@ -100,12 +100,6 @@ DAPI_(HRESULT) PathGetDirectory(
100 return S_FALSE;
101 }
102
103 - if (wzPath[0] == L'\"')
104 - {
105 - ++wzPath;
106 - --cchDirectory;
107 - }
108 -
103 hr = StrAllocString(psczDirectory, wzPath, cchDirectory);
104 PathExitOnFailure(hr, "Failed to copy directory.");
105
src/libs/dutil/test/DUtilUnitTest/PathUtilTest.cpp
+33
@@ -11,6 +11,39 @@ namespace DutilTests
11 public ref class PathUtil
12 {
13 public:
14 + [Fact]
15 + void PathGetDirectoryTest()
16 + {
17 + HRESULT hr = S_OK;
18 + LPWSTR sczPath = NULL;
19 + LPCWSTR rgwzPaths[18] =
20 + {
21 + L"C:\\a\\b", L"C:\\a\\",
22 + L"C:\\a", L"C:\\",
23 + L"C:\\", L"C:\\",
24 + L"\"C:\\a\\b\\c\"", L"\"C:\\a\\b\\",
25 + L"\"C:\\a\\b\\\"c", L"\"C:\\a\\b\\",
26 + L"\"C:\\a\\b\"\\c", L"\"C:\\a\\b\"\\",
27 + L"\"C:\\a\\\"b\\c", L"\"C:\\a\\\"b\\",
28 + L"C:\\a\"\\\"b\\c", L"C:\\a\"\\\"b\\",
29 + L"C:\\a\"\\b\\c\"", L"C:\\a\"\\b\\",
30 + };
31 +
32 + try
33 + {
34 + for (DWORD i = 0; i < countof(rgwzPaths); i += 2)
35 + {
36 + hr = PathGetDirectory(rgwzPaths[i], &sczPath);
37 + NativeAssert::Succeeded(hr, "PathGetDirectory: {0}", rgwzPaths[i]);
38 + NativeAssert::StringEqual(rgwzPaths[i + 1], sczPath);
39 + }
40 + }
41 + finally
42 + {
43 + ReleaseStr(sczPath);
44 + }
45 + }
46 +
47 [Fact]
48 void PathGetHierarchyArrayTest()
49 {