Skip to content

Commit

Permalink
Fixed endless loop that would happen if an attribute was omitted in a…
Browse files Browse the repository at this point in the history
… predicate instantiation
  • Loading branch information
cassidydotdk committed May 4, 2021
1 parent 8716fe4 commit b0ae957
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/SharedAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[assembly: AssemblyProduct("Unicorn")]
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("4.1.4.0")]
[assembly: AssemblyFileVersion("4.1.4.0")]
[assembly: AssemblyInformationalVersion("4.1.4")]
[assembly: AssemblyVersion("4.1.5.0")]
[assembly: AssemblyFileVersion("4.1.5.0")]
[assembly: AssemblyInformationalVersion("4.1.5-pre1")]
[assembly: CLSCompliant(false)]
7 changes: 6 additions & 1 deletion src/Unicorn/Configuration/PredicatePreset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,19 @@ protected virtual XmlElement ReplaceValues(Dictionary<string, string> replacers,
// ReSharper disable once PossibleNullReferenceException
foreach (XmlNode att in clone.Attributes)
{
while (att.Value.Contains("$"))
if (att.Value.Contains("$"))
{
didReplacement = true;

foreach (var replacerKey in replacers.Keys)
{
att.Value = Regex.Replace(att.Value, "\\$" + replacerKey, replacers[replacerKey], RegexOptions.IgnoreCase);
}

if (att.Value.Contains("$"))
{
throw new InvalidOperationException($"Predicate Preset '{((XmlElement)includeElement.ParentNode).Attributes["id"].Value}' could not be expanded, there are unresolved token attributes '{att.Value}'");
}
}
}

Expand Down

0 comments on commit b0ae957

Please sign in to comment.