Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Net;

namespace Azure.Sdk.Tools.TestProxy.Sanitizers
{
Expand Down Expand Up @@ -44,25 +43,28 @@ public BodyKeySanitizer(string jsonPath, string value = "Sanitized", string rege
public override string SanitizeTextBody(string contentType, string body)
{
bool sanitized = false;
JToken jsonO;
JToken jsonO = null;

try
if (contentType.ToLower().Contains("json"))
{
// Prevent default behavior where JSON.NET will convert DateTimeOffset
// into a DateTime.
if (!LegacyConvertJsonDateTokens)
try
{
jsonO = JsonConvert.DeserializeObject<JToken>(body, SerializerSettings);
// Prevent default behavior where JSON.NET will convert DateTimeOffset
// into a DateTime.
if (!LegacyConvertJsonDateTokens)
{
jsonO = JsonConvert.DeserializeObject<JToken>(body, SerializerSettings);
}
else
{
jsonO = JToken.Parse(body);
}
}
else
catch (JsonReaderException)
{
jsonO = JToken.Parse(body);
return body;
}
}
catch(JsonReaderException)
{
return body;
}

if (jsonO != null)
{
Expand Down