From e1599b59acc000cc12a79e7b205eb402c614ee31 Mon Sep 17 00:00:00 2001 From: Francisco Gamino Date: Thu, 1 Jun 2017 11:15:17 -0700 Subject: [PATCH] Update regular expression to filter out Json contents that do not start with an array for ConvertFrom-Json. (#3882) --- .../commands/utility/WebCmdlet/JsonObject.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/JsonObject.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/JsonObject.cs index 6561c4699..28c443d47 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/JsonObject.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/JsonObject.cs @@ -53,8 +53,8 @@ namespace Microsoft.PowerShell.Commands // This issue is being tracked by https://github.com/JamesNK/Newtonsoft.Json/issues/1321. // To work around this, we need to identify when input is a Json array, and then try to parse it via JArray.Parse(). - // If input starts with '[' or ends with ']' (ignoring white spaces). - if ((Regex.Match(input, @"(^\s*\[)|(\s*\]$)")).Success) + // If input starts with '[' (ignoring white spaces). + if ((Regex.Match(input, @"^\s*\[")).Success) { // JArray.Parse() will throw a JsonException if the array is invalid. // This will be caught by the catch block below, and then throw an