Fix loc and wix variables to allow dots in their identifier name again
Fixes 8713
Rob Mensching committed
Dec 26, 2024 at 13:24 UTC
b1e207c28833978a902d7411daa2f4bde41bf962
2 files changed
+14
-6
src/wix/WixToolset.Core/Common.cs
+2
-1
@@ -765,7 +765,8 @@ namespace WixToolset.Core
765
766
var equalsDefaultValue = value.IndexOf('=', firstDot + 1, closeParen - firstDot);
767
var end = equalsDefaultValue == -1 ? closeParen : equalsDefaultValue;
768
- var secondDot = value.IndexOf('.', firstDot + 1, end - firstDot);
768
+ // bind variables may have a second dot to define their scope, other variables do not have scope and ignore additional dots.
769
+ var secondDot = ns == "bind" ? value.IndexOf('.', firstDot + 1, end - firstDot) : -1;
770
771
if (secondDot == -1)
772
{
src/wix/test/WixToolsetTest.Core/VariableResolverFixture.cs
+12
-5
@@ -3,6 +3,7 @@
3
namespace WixToolsetTest.Core
4
{
5
using System.Collections.Generic;
6
+ using System.Linq;
7
using WixInternal.TestSupport;
8
using WixToolset.Core;
9
using WixToolset.Data;
@@ -18,12 +19,14 @@ namespace WixToolsetTest.Core
19
var serviceProvider = WixToolsetServiceProviderFactory.CreateServiceProvider();
20
var variableResolver = serviceProvider.GetService<IVariableResolver>();
21
21
- var variables = new Dictionary<string, BindVariable>()
22
+ var variables = new BindVariable[]
23
{
23
- { "ProductName", new BindVariable() { Id = "ProductName", Value = "Localized Product Name" } },
24
- { "ProductNameEdition", new BindVariable() { Id = "ProductNameEdition", Value = "!(loc.ProductName) Enterprise Edition" } },
25
- { "ProductNameEditionVersion", new BindVariable() { Id = "ProductNameEditionVersion", Value = "!(loc.ProductNameEdition) v1.2.3" } },
26
- };
24
+ new() { Id = "ProductName", Value = "Localized Product Name" },
25
+ new() { Id = "ProductNameEdition", Value = "!(loc.ProductName) Enterprise Edition" },
26
+ new() { Id = "ProductNameEditionVersion", Value = "!(loc.ProductNameEdition) v1.2.3" },
27
+ new() { Id = "Dotted.Loc.Variable", Value = "Dotted.Loc.Variable = !(loc.ProductNameEditionVersion)" },
28
+ new() { Id = "NestedDotted.Loc.Variable", Value = "!(loc.Dotted.Loc.Variable) worked" },
29
+ }.ToDictionary(b => b.Id);
30
31
var localization = new Localization(0, null, "x-none", variables, new Dictionary<string, LocalizedControl>());
32
@@ -45,6 +48,10 @@ namespace WixToolsetTest.Core
48
WixAssert.StringEqual("Welcome to Localized Product Name Enterprise Edition v1.2.3", result.Value);
49
Assert.True(result.UpdatedValue);
50
51
+ result = variableResolver.ResolveVariables(null, "start !(loc.NestedDotted.Loc.Variable) end");
52
+ WixAssert.StringEqual("start Dotted.Loc.Variable = Localized Product Name Enterprise Edition v1.2.3 worked end", result.Value);
53
+ Assert.True(result.UpdatedValue);
54
+
55
result = variableResolver.ResolveVariables(null, "Welcome to !(bind.property.ProductVersion)");
56
WixAssert.StringEqual("Welcome to !(bind.property.ProductVersion)", result.Value);
57
Assert.False(result.UpdatedValue);