From ab8d368fe8e7a41e503ec295b196035922293ef4 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Thu, 27 Apr 2023 21:06:35 -0400 Subject: Fix XmlConfig lookup logic. Fixes https://github.com/wixtoolset/issues/issues/7377. Requires fix for https://github.com/wixtoolset/issues/issues/7444. --- src/ext/Util/ca/XmlConfig.cpp | 13 ++++--------- .../TestData/XmlConfig/Package.wxs | 22 ++++++++++++++++------ .../WixToolsetTest.Util/TestData/XmlConfig/my.xml | 11 +++++++++++ .../WixToolsetTest.Util/UtilExtensionFixture.cs | 6 +++++- 4 files changed, 36 insertions(+), 16 deletions(-) create mode 100644 src/ext/Util/test/WixToolsetTest.Util/TestData/XmlConfig/my.xml (limited to 'src/ext') diff --git a/src/ext/Util/ca/XmlConfig.cpp b/src/ext/Util/ca/XmlConfig.cpp index 2014e15f..3f059435 100644 --- a/src/ext/Util/ca/XmlConfig.cpp +++ b/src/ext/Util/ca/XmlConfig.cpp @@ -266,11 +266,11 @@ static HRESULT ProcessChanges( // Keep track of where our next spot will be since our current node may be moved pxfcNext = pxfc->pxfcNext; - // With each node, check to see if it's element path matches the Id of some other node in the list + // With each node, check to see if its element path matches the Id of some other node in the list pxfcCheck = *ppxfcHead; while (pxfcCheck) { - if (pxfc->pwzElementId) + if (pxfc->pwzElementId && *pxfc->pwzElementId) { if (0 == lstrcmpW(pxfc->pwzElementId, pxfcCheck->wzId) && 0 == pxfc->iXmlFlags @@ -315,11 +315,6 @@ static HRESULT ProcessChanges( pxfcCheck->cAdditionalChanges = ++cAdditionalChanges; } } - else - { - hr = E_NOTFOUND; - ExitOnRootFailure(hr, "failed to find matching ElementId: %ls", pxfc->pwzElementId); - } } pxfcCheck = pxfcCheck->pxfcNext; @@ -402,10 +397,10 @@ static HRESULT WriteChangeData( HRESULT hr = S_OK; XML_CONFIG_CHANGE* pxfcAdditionalChanges = NULL; - LPCWSTR wzElementPath = pxfc->pwzElementId ? pxfc->pwzElementId : pxfc->pwzElementPath; + LPCWSTR wzElementPath = pxfc->pwzElementId && *pxfc->pwzElementId ? pxfc->pwzElementId : pxfc->pwzElementPath; hr = WcaWriteStringToCaData(wzElementPath, ppwzCustomActionData); - ExitOnFailure(hr, "failed to write ElementPath to custom action data: %ls", wzElementPath); + ExitOnFailure(hr, "failed to write ElementId/ElementPath to custom action data: %ls", wzElementPath); hr = WcaWriteStringToCaData(pxfc->pwzVerifyPath, ppwzCustomActionData); ExitOnFailure(hr, "failed to write VerifyPath to custom action data: %ls", pxfc->pwzVerifyPath); diff --git a/src/ext/Util/test/WixToolsetTest.Util/TestData/XmlConfig/Package.wxs b/src/ext/Util/test/WixToolsetTest.Util/TestData/XmlConfig/Package.wxs index a2002634..cb132960 100644 --- a/src/ext/Util/test/WixToolsetTest.Util/TestData/XmlConfig/Package.wxs +++ b/src/ext/Util/test/WixToolsetTest.Util/TestData/XmlConfig/Package.wxs @@ -1,17 +1,27 @@ - + + + + + - + + + + + + + - - - - + + + + diff --git a/src/ext/Util/test/WixToolsetTest.Util/TestData/XmlConfig/my.xml b/src/ext/Util/test/WixToolsetTest.Util/TestData/XmlConfig/my.xml new file mode 100644 index 00000000..3f44c27c --- /dev/null +++ b/src/ext/Util/test/WixToolsetTest.Util/TestData/XmlConfig/my.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/ext/Util/test/WixToolsetTest.Util/UtilExtensionFixture.cs b/src/ext/Util/test/WixToolsetTest.Util/UtilExtensionFixture.cs index 817ab7c9..e04252da 100644 --- a/src/ext/Util/test/WixToolsetTest.Util/UtilExtensionFixture.cs +++ b/src/ext/Util/test/WixToolsetTest.Util/UtilExtensionFixture.cs @@ -10,6 +10,7 @@ namespace WixToolsetTest.Util using WixToolset.Util; using Xunit; using System.Xml.Linq; + using System; public class UtilExtensionFixture { @@ -293,7 +294,10 @@ namespace WixToolsetTest.Util var results = build.BuildAndQuery(BuildX64, "Wix4XmlConfig"); WixAssert.CompareLineByLine(new[] { - "Wix4XmlConfig:DelElement\t[INSTALLFOLDER]my.xml\t\t//root/sub\txxx\t\t\t289\tDel\t1", + "Wix4XmlConfig:AddAttribute2\t[INSTALLFOLDER]my.xml\tAddElement\t\t\tTheAttribute2\tAttributeValue2\t0\tAdd\t4", + "Wix4XmlConfig:AddElement\t[#MyXmlFile]\t\t//root/child2\t\tgrandchild3\t\t273\tAdd\t2", + "Wix4XmlConfig:DelElement\t[#MyXmlFile]\t\t//root/child1\tgrandchild1\t\t\t289\tDel\t", + "Wix4XmlConfig:uxcPPF6g4HJEQpBLT9w9GT6SKyHWww\t[#MyXmlFile]\tAddElement\t\t\tTheAttribute1\tAttributeValue1\t0\tAdd\t3", }, results.OrderBy(s => s).ToArray()); } -- cgit v1.2.3-55-g6feb