Skip to content

Commit 8dae539

Browse files
authored
Don't try to parse JSON strings as date (#1492)
When parsing launch options from JSON, the JSON parser's default behavior is – for whatever reason – to parse slightly datetime-ish looking strings as date objects. This PR explicitly forbids this behavior when parsing launch options. Partially fixes #1491, microsoft/vscode-cpptools#13241 and microsoft/vscode#238514.
1 parent 6c54916 commit 8dae539

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/MICore/LaunchOptions.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,11 @@ public static LaunchOptions GetInstance(HostConfigurationStore configStore, stri
12671267
{
12681268
try
12691269
{
1270-
JObject parsedOptions = JObject.Parse(options);
1270+
JObject parsedOptions = JsonConvert.DeserializeObject<JObject>(options, new JsonSerializerSettings { DateParseHandling = DateParseHandling.None });
1271+
if (parsedOptions is null)
1272+
{
1273+
throw new InvalidLaunchOptionsException(MICoreResources.Error_UnknownLaunchOptions);
1274+
}
12711275

12721276
// if the customLauncher element is present then try using the custom launcher implementation from the config store
12731277
if (parsedOptions["customLauncher"] != null && !string.IsNullOrWhiteSpace(parsedOptions["customLauncher"].Value<string>()))

0 commit comments

Comments
 (0)