Skip to content

Commit 8ba24c9

Browse files
committed
Added regex to check for enclosed string with filter bound parameter
1 parent 66baa65 commit 8ba24c9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tools/Custom/PSCmdletExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace NamespacePrefixPlaceholder.PowerShell
1818
internal static class PSCmdletExtensions
1919
{
2020
private static readonly char[] PathSeparators = new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar };
21+
private static readonly Regex EnclosedStringRegex = new Regex(@"'.*?'| "".*?""", RegexOptions.Compiled, TimeSpan.FromSeconds(1));
2122

2223
// Converts a string to its unescaped form. The method also replaces '+' with spaces.
2324
internal static string UnescapeString(this PSCmdlet cmdlet, string value)
@@ -28,7 +29,7 @@ internal static string UnescapeString(this PSCmdlet cmdlet, string value)
2829
try
2930
{
3031
var unescapedString = Uri.UnescapeDataString(value);
31-
return value.Contains("displayName") ? unescapedString: unescapedString.Replace('+', ' ');
32+
return EnclosedStringRegex.IsMatch(value) ? unescapedString: unescapedString.Replace('+', ' ');
3233
}
3334
catch (UriFormatException ex)
3435
{

0 commit comments

Comments
 (0)