Fix ArgumentOutOfRangeException in PowerShellPostAmpersandEscape. (#2875)

This commit is contained in:
Tingluo Huang
2023-09-21 12:34:28 -04:00
committed by GitHub
parent 8c917b4ad3
commit 67d70803a9
2 changed files with 6 additions and 2 deletions

View File

@@ -123,8 +123,11 @@ namespace GitHub.DistributedTask.Logging
var secretSection = string.Empty;
if (value.Contains("&+"))
{
// +1 to skip the letter that got colored
secretSection = value.Substring(value.IndexOf("&+") + "&+".Length + 1);
if (value.Length > value.IndexOf("&+") + "&+".Length + 1)
{
// +1 to skip the letter that got colored
secretSection = value.Substring(value.IndexOf("&+") + "&+".Length + 1);
}
}
else
{