From 4aeddc38313db98e15563d552dbadc8ad071a368 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Tue, 20 May 2025 21:44:47 +1000 Subject: [PATCH] use char based APIs in TryUnescape --- src/Platform/Microsoft.Testing.Platform/CommandLine/Parser.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Platform/Microsoft.Testing.Platform/CommandLine/Parser.cs b/src/Platform/Microsoft.Testing.Platform/CommandLine/Parser.cs index 61551e2c83c..0e95742763b 100644 --- a/src/Platform/Microsoft.Testing.Platform/CommandLine/Parser.cs +++ b/src/Platform/Microsoft.Testing.Platform/CommandLine/Parser.cs @@ -145,7 +145,7 @@ static bool TryUnescape(string input, string? option, IEnvironment environment, // Enclosing characters in single-quotes ( '' ) shall preserve the literal value of each character within the single-quotes. // A single-quote cannot occur within single-quotes. - if (input.StartsWith(@"'", StringComparison.OrdinalIgnoreCase) && input.EndsWith(@"'", StringComparison.OrdinalIgnoreCase)) + if (input.StartsWith('\'') && input.EndsWith('\'')) { if (input.IndexOf('\'', 1, input.Length - 2) != -1) { @@ -165,7 +165,7 @@ static bool TryUnescape(string input, string? option, IEnvironment environment, // * The shall retain its special meaning introducing parameter expansion. [NOT SUPPORTED] // * The backslash shall retain its special meaning as an escape character only when followed by one of the following characters when considered special: // $ ` " \ - if (input.StartsWith("\"", StringComparison.OrdinalIgnoreCase) && input.EndsWith("\"", StringComparison.OrdinalIgnoreCase)) + if (input.StartsWith('"') && input.EndsWith('"')) { unescapedArg = input[1..^1].Replace(@"\\", "\\") .Replace(@"\""", "\"")