diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2021-07-01 09:30:10 -0500 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2021-07-02 12:50:09 -0500 |
| commit | 9bdf3730cd43e1af8a4ea9be6cf2fba77fcff2d2 (patch) | |
| tree | ea2a05de5a8a1dfcb2af8e9e3805fe015729f66a /src/api/burn/balutil | |
| parent | 8cbfc326cccf8d9b3b63cb6f752fc770f7dee0fc (diff) | |
| download | wix-9bdf3730cd43e1af8a4ea9be6cf2fba77fcff2d2.tar.gz wix-9bdf3730cd43e1af8a4ea9be6cf2fba77fcff2d2.tar.bz2 wix-9bdf3730cd43e1af8a4ea9be6cf2fba77fcff2d2.zip | |
Add bundle option for command line variables to always be uppercase.
Fixes #3777
Diffstat (limited to 'src/api/burn/balutil')
| -rw-r--r-- | src/api/burn/balutil/balinfo.cpp | 40 | ||||
| -rw-r--r-- | src/api/burn/balutil/inc/balinfo.h | 7 |
2 files changed, 47 insertions, 0 deletions
diff --git a/src/api/burn/balutil/balinfo.cpp b/src/api/burn/balutil/balinfo.cpp index 5927ef72..f71784a5 100644 --- a/src/api/burn/balutil/balinfo.cpp +++ b/src/api/burn/balutil/balinfo.cpp | |||
| @@ -292,6 +292,7 @@ DAPI_(HRESULT) BalSetOverridableVariablesFromEngine( | |||
| 292 | ) | 292 | ) |
| 293 | { | 293 | { |
| 294 | HRESULT hr = S_OK; | 294 | HRESULT hr = S_OK; |
| 295 | LPWSTR sczKey = NULL; | ||
| 295 | BAL_INFO_OVERRIDABLE_VARIABLE* pOverridableVariable = NULL; | 296 | BAL_INFO_OVERRIDABLE_VARIABLE* pOverridableVariable = NULL; |
| 296 | 297 | ||
| 297 | for (DWORD i = 0; i < pCommand->cVariables; ++i) | 298 | for (DWORD i = 0; i < pCommand->cVariables; ++i) |
| @@ -299,6 +300,14 @@ DAPI_(HRESULT) BalSetOverridableVariablesFromEngine( | |||
| 299 | LPCWSTR wzVariableName = pCommand->rgVariableNames[i]; | 300 | LPCWSTR wzVariableName = pCommand->rgVariableNames[i]; |
| 300 | LPCWSTR wzVariableValue = pCommand->rgVariableValues[i]; | 301 | LPCWSTR wzVariableValue = pCommand->rgVariableValues[i]; |
| 301 | 302 | ||
| 303 | if (BAL_INFO_VARIABLE_COMMAND_LINE_TYPE_UPPER_CASE == pOverridableVariables->commandLineType) | ||
| 304 | { | ||
| 305 | hr = StrAllocStringToUpperInvariant(&sczKey, wzVariableName, 0); | ||
| 306 | ExitOnFailure(hr, "Failed to upper case variable name."); | ||
| 307 | |||
| 308 | wzVariableName = sczKey; | ||
| 309 | } | ||
| 310 | |||
| 302 | hr = DictGetValue(pOverridableVariables->sdVariables, wzVariableName, reinterpret_cast<void**>(&pOverridableVariable)); | 311 | hr = DictGetValue(pOverridableVariables->sdVariables, wzVariableName, reinterpret_cast<void**>(&pOverridableVariable)); |
| 303 | if (E_NOTFOUND == hr) | 312 | if (E_NOTFOUND == hr) |
| 304 | { | 313 | { |
| @@ -313,6 +322,8 @@ DAPI_(HRESULT) BalSetOverridableVariablesFromEngine( | |||
| 313 | } | 322 | } |
| 314 | 323 | ||
| 315 | LExit: | 324 | LExit: |
| 325 | ReleaseStr(sczKey); | ||
| 326 | |||
| 316 | return hr; | 327 | return hr; |
| 317 | } | 328 | } |
| 318 | 329 | ||
| @@ -527,10 +538,37 @@ static HRESULT ParseOverridableVariablesFromXml( | |||
| 527 | ) | 538 | ) |
| 528 | { | 539 | { |
| 529 | HRESULT hr = S_OK; | 540 | HRESULT hr = S_OK; |
| 541 | IXMLDOMNode* pCommandLineNode = NULL; | ||
| 542 | LPWSTR scz = NULL; | ||
| 530 | IXMLDOMNode* pNode = NULL; | 543 | IXMLDOMNode* pNode = NULL; |
| 531 | IXMLDOMNodeList* pNodes = NULL; | 544 | IXMLDOMNodeList* pNodes = NULL; |
| 532 | BAL_INFO_OVERRIDABLE_VARIABLE* pOverridableVariable = NULL; | 545 | BAL_INFO_OVERRIDABLE_VARIABLE* pOverridableVariable = NULL; |
| 533 | 546 | ||
| 547 | hr = XmlSelectSingleNode(pixdManifest, L"/BootstrapperApplicationData/CommandLine", &pCommandLineNode); | ||
| 548 | if (S_FALSE == hr) | ||
| 549 | { | ||
| 550 | hr = E_NOTFOUND; | ||
| 551 | } | ||
| 552 | ExitOnFailure(hr, "Failed to select command line information."); | ||
| 553 | |||
| 554 | // @Variables | ||
| 555 | hr = XmlGetAttributeEx(pCommandLineNode, L"Variables", &scz); | ||
| 556 | ExitOnFailure(hr, "Failed to get command line variable type."); | ||
| 557 | |||
| 558 | if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"upperCase", -1)) | ||
| 559 | { | ||
| 560 | pOverridableVariables->commandLineType = BAL_INFO_VARIABLE_COMMAND_LINE_TYPE_UPPER_CASE; | ||
| 561 | } | ||
| 562 | else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"caseSensitive", -1)) | ||
| 563 | { | ||
| 564 | pOverridableVariables->commandLineType = BAL_INFO_VARIABLE_COMMAND_LINE_TYPE_CASE_SENSITIVE; | ||
| 565 | } | ||
| 566 | else | ||
| 567 | { | ||
| 568 | hr = E_INVALIDARG; | ||
| 569 | ExitOnFailure(hr, "Invalid value for CommandLine/@Variables: %ls", scz); | ||
| 570 | } | ||
| 571 | |||
| 534 | // Get the list of variables users can override on the command line. | 572 | // Get the list of variables users can override on the command line. |
| 535 | hr = XmlSelectNodes(pixdManifest, L"/BootstrapperApplicationData/WixStdbaOverridableVariable", &pNodes); | 573 | hr = XmlSelectNodes(pixdManifest, L"/BootstrapperApplicationData/WixStdbaOverridableVariable", &pNodes); |
| 536 | if (S_FALSE == hr) | 574 | if (S_FALSE == hr) |
| @@ -570,6 +608,8 @@ static HRESULT ParseOverridableVariablesFromXml( | |||
| 570 | } | 608 | } |
| 571 | 609 | ||
| 572 | LExit: | 610 | LExit: |
| 611 | ReleaseStr(scz); | ||
| 612 | ReleaseObject(pCommandLineNode); | ||
| 573 | ReleaseObject(pNode); | 613 | ReleaseObject(pNode); |
| 574 | ReleaseObject(pNodes); | 614 | ReleaseObject(pNodes); |
| 575 | return hr; | 615 | return hr; |
diff --git a/src/api/burn/balutil/inc/balinfo.h b/src/api/burn/balutil/inc/balinfo.h index 0fce35ec..07a1cbb7 100644 --- a/src/api/burn/balutil/inc/balinfo.h +++ b/src/api/burn/balutil/inc/balinfo.h | |||
| @@ -18,6 +18,12 @@ typedef enum BAL_INFO_PACKAGE_TYPE | |||
| 18 | BAL_INFO_PACKAGE_TYPE_BUNDLE_PATCH, | 18 | BAL_INFO_PACKAGE_TYPE_BUNDLE_PATCH, |
| 19 | } BAL_INFO_PACKAGE_TYPE; | 19 | } BAL_INFO_PACKAGE_TYPE; |
| 20 | 20 | ||
| 21 | typedef enum _BAL_INFO_VARIABLE_COMMAND_LINE_TYPE | ||
| 22 | { | ||
| 23 | BAL_INFO_VARIABLE_COMMAND_LINE_TYPE_UPPER_CASE, | ||
| 24 | BAL_INFO_VARIABLE_COMMAND_LINE_TYPE_CASE_SENSITIVE, | ||
| 25 | } BAL_INFO_VARIABLE_COMMAND_LINE_TYPE; | ||
| 26 | |||
| 21 | 27 | ||
| 22 | typedef struct _BAL_INFO_PACKAGE | 28 | typedef struct _BAL_INFO_PACKAGE |
| 23 | { | 29 | { |
| @@ -58,6 +64,7 @@ typedef struct _BAL_INFO_OVERRIDABLE_VARIABLES | |||
| 58 | BAL_INFO_OVERRIDABLE_VARIABLE* rgVariables; | 64 | BAL_INFO_OVERRIDABLE_VARIABLE* rgVariables; |
| 59 | DWORD cVariables; | 65 | DWORD cVariables; |
| 60 | STRINGDICT_HANDLE sdVariables; | 66 | STRINGDICT_HANDLE sdVariables; |
| 67 | BAL_INFO_VARIABLE_COMMAND_LINE_TYPE commandLineType; | ||
| 61 | } BAL_INFO_OVERRIDABLE_VARIABLES; | 68 | } BAL_INFO_OVERRIDABLE_VARIABLES; |
| 62 | 69 | ||
| 63 | 70 | ||
