From fe300b68a6cb0fb01ac5823be0351dd7c9affc7a Mon Sep 17 00:00:00 2001 From: Lokesh Gopu Date: Fri, 15 Sep 2023 00:33:33 -0400 Subject: [PATCH] handle secret ending with &+ --- src/Sdk/DTLogging/Logging/ValueEncoders.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Sdk/DTLogging/Logging/ValueEncoders.cs b/src/Sdk/DTLogging/Logging/ValueEncoders.cs index d7f02ae6a..4f189b9f4 100644 --- a/src/Sdk/DTLogging/Logging/ValueEncoders.cs +++ b/src/Sdk/DTLogging/Logging/ValueEncoders.cs @@ -98,7 +98,17 @@ namespace GitHub.DistributedTask.Logging var secretSection = string.Empty; if (value.Contains("&+")) { - secretSection = value.Substring(0, value.IndexOf("&+") + "&+".Length); + int endIndex = value.IndexOf("&+") + "&+".Length; + + // If string ends with "&+", grab the whole string + if (endIndex == value.Length) + { + secretSection = value; + } + else + { + secretSection = value.Substring(0, endIndex); + } } else {