aboutsummaryrefslogtreecommitdiff
path: root/src/ext
diff options
context:
space:
mode:
Diffstat (limited to 'src/ext')
-rw-r--r--src/ext/NetFx/ca/netfxca.cpp58
-rw-r--r--src/ext/NetFx/ca/precomp.h1
2 files changed, 59 insertions, 0 deletions
diff --git a/src/ext/NetFx/ca/netfxca.cpp b/src/ext/NetFx/ca/netfxca.cpp
index 1182464e..f0704790 100644
--- a/src/ext/NetFx/ca/netfxca.cpp
+++ b/src/ext/NetFx/ca/netfxca.cpp
@@ -280,6 +280,64 @@ LExit:
280 return hr; 280 return hr;
281} 281}
282 282
283// This has netfxca specific functionality, like turning " into "" and leaving an unescaped \ at the end of a directory.
284static HRESULT PathEnsureQuoted(
285 __inout LPWSTR* ppszPath,
286 __in BOOL fDirectory
287 )
288{
289 Assert(ppszPath && *ppszPath);
290
291 HRESULT hr = S_OK;
292 size_t cchPath = 0;
293
294 hr = ::StringCchLengthW(*ppszPath, STRSAFE_MAX_CCH, &cchPath);
295 ExitOnFailure(hr, "Failed to get the length of the path.");
296
297 // Handle simple special cases.
298 if (0 == cchPath || (1 == cchPath && L'"' == (*ppszPath)[0]))
299 {
300 hr = StrAllocString(ppszPath, L"\"\"", 2);
301 ExitOnFailure(hr, "Failed to allocate a quoted empty string.");
302
303 ExitFunction();
304 }
305
306 if (L'"' != (*ppszPath)[0])
307 {
308 hr = StrAllocPrefix(ppszPath, L"\"", 1);
309 ExitOnFailure(hr, "Failed to allocate an opening quote.");
310
311 // Add a char for the opening quote.
312 ++cchPath;
313 }
314
315 if (L'"' != (*ppszPath)[cchPath - 1])
316 {
317 hr = StrAllocConcat(ppszPath, L"\"", 1);
318 ExitOnFailure(hr, "Failed to allocate a closing quote.");
319
320 // Add a char for the closing quote.
321 ++cchPath;
322 }
323
324 if (fDirectory)
325 {
326 if (L'\\' != (*ppszPath)[cchPath - 2])
327 {
328 // Change the last char to a backslash and re-append the closing quote.
329 (*ppszPath)[cchPath - 1] = L'\\';
330
331 hr = StrAllocConcat(ppszPath, L"\"", 1);
332 ExitOnFailure(hr, "Failed to allocate another closing quote after the backslash.");
333 }
334 }
335
336LExit:
337
338 return hr;
339}
340
283static HRESULT CreateInstallCommand( 341static HRESULT CreateInstallCommand(
284 __out LPWSTR* ppwzCommandLine, 342 __out LPWSTR* ppwzCommandLine,
285 __in LPCWSTR pwzNgenPath, 343 __in LPCWSTR pwzNgenPath,
diff --git a/src/ext/NetFx/ca/precomp.h b/src/ext/NetFx/ca/precomp.h
index 4a83c164..f7b537ed 100644
--- a/src/ext/NetFx/ca/precomp.h
+++ b/src/ext/NetFx/ca/precomp.h
@@ -4,6 +4,7 @@
4 4
5#include <windows.h> 5#include <windows.h>
6#include <msiquery.h> 6#include <msiquery.h>
7#include <strsafe.h>
7 8
8#include "wcautil.h" 9#include "wcautil.h"
9#include "fileutil.h" 10#include "fileutil.h"