add secret masker for trimming double qoutes. (#440)

This commit is contained in:
Tingluo Huang
2020-04-21 22:07:55 -04:00
committed by GitHub
parent d5c54f9819
commit 3f7a01af93
3 changed files with 20 additions and 0 deletions

View File

@@ -60,6 +60,20 @@ namespace GitHub.DistributedTask.Logging
return SecurityElement.Escape(value);
}
public static String TrimDoubleQuotes(String value)
{
var trimmed = string.Empty;
if (!string.IsNullOrEmpty(value) &&
value.Length > 8 &&
value.StartsWith('"') &&
value.EndsWith('"'))
{
trimmed = value.Substring(1, value.Length - 2);
}
return trimmed;
}
private static string Base64StringEscapeShift(String value, int shift)
{
var bytes = Encoding.UTF8.GetBytes(value);