@joebigelow / wix / commits / c37f29a1

Fix parsing of bind variables with default values

Rob Mensching committed Jul 17, 2020 at 10:42 UTC c37f29a156a84e27e6b38a7841e2ddcde015b071
5 files changed +49 -2
src/WixToolset.Core/Common.cs
+2 -2
@@ -788,9 +788,9 @@ namespace WixToolset.Core
788 string scope = null;
789 string defaultValue = null;
790
791 - var secondDot = value.IndexOf('.', firstDot + 1, closeParen - firstDot);
791 var equalsDefaultValue = value.IndexOf('=', firstDot + 1, closeParen - firstDot);
792 var end = equalsDefaultValue == -1 ? closeParen : equalsDefaultValue;
793 + var secondDot = value.IndexOf('.', firstDot + 1, end - firstDot);
794
795 if (secondDot == -1)
796 {
@@ -814,7 +814,7 @@ namespace WixToolset.Core
814
815 if (equalsDefaultValue != -1 && equalsDefaultValue < closeParen)
816 {
817 - defaultValue = value.Substring(equalsDefaultValue + 1, end - equalsDefaultValue - 1);
817 + defaultValue = value.Substring(equalsDefaultValue + 1, closeParen - equalsDefaultValue - 1);
818 }
819
820 parsedVariable = new ParsedWixVariable
src/test/WixToolsetTest.CoreIntegration/BindVariablesFixture.cs new
+38
@@ -0,0 +1,38 @@
1 +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2 +
3 +namespace WixToolsetTest.CoreIntegration
4 +{
5 + using System;
6 + using System.IO;
7 + using WixBuildTools.TestSupport;
8 + using WixToolset.Core.TestPackage;
9 + using Xunit;
10 +
11 + public class BindVariablesFixture
12 + {
13 + [Fact]
14 + public void CanBuildWithDefaultValue()
15 + {
16 + var folder = TestData.Get(@"TestData\BindVariables");
17 +
18 + using (var fs = new DisposableFileSystem())
19 + {
20 + var baseFolder = fs.GetFolder();
21 + var intermediateFolder = Path.Combine(baseFolder, "obj");
22 + var wixlibPath = Path.Combine(intermediateFolder, @"test.wixlib");
23 +
24 + var result = WixRunner.Execute(new[]
25 + {
26 + "build",
27 + Path.Combine(folder, "DefaultedVariable.wxs"),
28 + "-bf",
29 + "-intermediateFolder", intermediateFolder,
30 + "-bindpath", folder,
31 + "-o", wixlibPath,
32 + });
33 +
34 + result.AssertSuccess();
35 + }
36 + }
37 + }
38 +}
src/test/WixToolsetTest.CoreIntegration/TestData/BindVariables/DefaultedVariable.wxs new
+6
@@ -0,0 +1,6 @@
1 +<?xml version="1.0" encoding="utf-8" ?>
2 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3 + <Fragment>
4 + <Binary Id="Bound" SourceFile="!(wix.Test=data\test.txt)" />
5 + </Fragment>
6 +</Wix>
src/test/WixToolsetTest.CoreIntegration/TestData/BindVariables/data/test.txt new
+1
@@ -0,0 +1 @@
1 +This is test.txt
src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj
+2
@@ -23,6 +23,8 @@
23 <Content Include="TestData\AppSearch\RegistrySearch.wxs" CopyToOutputDirectory="PreserveNewest" />
24 <Content Include="TestData\BadEnsureTable\BadEnsureTable.wxs" CopyToOutputDirectory="PreserveNewest" />
25 <Content Include="TestData\BadInput\RegistryKey.wxs" CopyToOutputDirectory="PreserveNewest" />
26 + <Content Include="TestData\BindVariables\DefaultedVariable.wxs" CopyToOutputDirectory="PreserveNewest" />
27 + <Content Include="TestData\BindVariables\data\test.txt" CopyToOutputDirectory="PreserveNewest" />
28 <Content Include="TestData\BundleCustomTable\BundleCustomTable.wxs" CopyToOutputDirectory="PreserveNewest" />
29 <Content Include="TestData\BundleExtension\BundleExtension.wxs" CopyToOutputDirectory="PreserveNewest" />
30 <Content Include="TestData\BundleExtension\BundleExtensionSearches.wxs" CopyToOutputDirectory="PreserveNewest" />